Ejemplo n.º 1
0
        public static void OnFinishMakeoverFreestyle(Sim actor, Sim target, string interaction, ActiveTopic topic, InteractionInstance i)
        {
            try
            {
                bool tookSemaphore = false;
                Styling.MakeoverOutcome makeoverOutcome = Styling.GetMakeoverOutcome(target, actor, true);
                bool forceFailureOutfit = makeoverOutcome == Styling.MakeoverOutcome.EpicFailure;
                bool flag3 = false;
                try
                {
                    if (forceFailureOutfit)
                    {
                        Styling.LoadMakeoverEpicFailureOutfitForCasOverride(target);
                    }
                    flag3 = GetMakeoverEx.DisplayCAS(target, actor, ref tookSemaphore, forceFailureOutfit);
                }
                catch (Exception)
                {
                    throw;
                }
                finally
                {
                    if (tookSemaphore)
                    {
                        GameStates.ReleaseInteractionStateChangeSemaphore();
                    }
                }

                if (CASChangeReporter.Instance.GetPropertyChanged(CASChangeReporter.ChangeFlags.Any))
                {
                    SkillLevel         customerReactionType = Styling.GetCustomerReactionType(target, actor, makeoverOutcome, false);
                    SkillLevel         stylerReactionType   = Styling.GetStylerReactionType(customerReactionType);
                    StateMachineClient client = StateMachineClient.Acquire(actor, "StylistActiveCareer");
                    client.SetActor("x", target);
                    client.SetActor("y", actor);
                    client.SetParameter("doClothesSpin", !flag3);
                    client.SetParameter("customerReactionType", customerReactionType);
                    client.SetParameter("stylistReactionType", stylerReactionType);
                    client.EnterState("x", "Enter");
                    client.EnterState("y", "Enter");
                    actor.LoopIdle();
                    client.RequestState("x", "Customer Reaction");
                    Styling.PostMakeover(target, actor, makeoverOutcome, false, customerReactionType, true, true, new Styling.OnMakeoverCompletedCallback(SocialCallback.OnMakeoverFreestyleCompleted));
                    client.RequestState(false, "x", "Exit");
                    client.RequestState("y", "Stylist Reaction");
                    client.RequestState("y", "Exit");
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(actor, target, e);
            }
        }
Ejemplo n.º 2
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteToFireplace(Actor))
                {
                    return(false);
                }

                if (!Target.mLit)
                {
                    return(false);
                }

                if (!Target.WaitToPutOut(Actor))
                {
                    return(false);
                }

                StandardEntry();
                BeginCommodityUpdates();
                Target.EnableFootprintAndPushSims(Target.FootprintPathingHash, Actor);

                MagicControl control = MagicControl.GetBestControl(Actor, CastIceBlastEx.Singleton as IMagicalDefinition);
                if (control != null)
                {
                    mProxy.Run(this, CastIceBlastEx.Singleton as IMagicalDefinition);

                    mWand.FinishUsing(Actor);
                }
                else
                {
                    StateMachineClient stateMachine = Target.GetStateMachine(this, "Enter");
                    stateMachine.SetParameter("HaveRemote", Target.TuningFireplace.HasRemote);
                    stateMachine.SetParameter("CheapVersion", Target.UseCheapAnimations);
                    stateMachine.AddOneShotScriptEventHandler(0x65, StopFireCallback);
                    stateMachine.RequestState("x", "ExtinguishFire");
                    stateMachine.RequestState("x", "Exit");
                }

                TraitFunctions.CheckForNeuroticAnxiety(Actor, TraitFunctions.NeuroticTraitAnxietyType.Fireplace);
                EndCommodityUpdates(true);
                StandardExit();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Ejemplo n.º 3
0
        public bool SitDownAndWait(StateMachineClient stateMachine)
        {
            if (isSitting)
            {
                stateMachine.SetParameter("isDirty", Target.Cleanable.NeedsToBeCleaned);
                Target.PutDownSeat(stateMachine);
                stateMachine.RequestState("x", "peeSitting");
                if (Target.SculptureComponent != null && Target.SculptureComponent.Material == Sims3.Gameplay.ObjectComponents.SculptureComponent.SculptureMaterial.Ice)
                {
                    Actor.BuffManager.AddElement(BuffNames.Chilly, Origin.FromSittingOnIce);
                }
                if (Target.ToiletTuning.AutoFlushes && RandomUtil.RandomChance((float)Toilet.kChanceOfToiletAutoFlushWhileInUse))
                {
                    stateMachine.RequestState("x", "flushReaction");
                }
                OccultImaginaryFriend.GrantMilestoneBuff(Actor, BuffNames.ImaginaryFriendFeelOfPorcelain, Origin.FromImaginaryFriendFirstTime, true, true, false);

                if (!Actor.WaitForSynchronizationLevelWithSim(LinkedInteractionInstance.InstanceActor, Sim.SyncLevel.Routed, 30f))
                {
                    FinishLinkedInteraction();
                    return(false);
                }
            }
            return(true);
        }
Ejemplo n.º 4
0
        public override bool Run()
        {
            try
            {
                StateMachineClient client = StateMachineClient.Acquire(Actor, "single_animation");
                client.SetActor("x", Actor);
                client.EnterState("x", "Enter");

                Definition definition = InteractionDefinition as Definition;

                Sim.AnimationClipDataForCAS rcas = definition.mAnimation;

                while (!Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
                {
                    if (!AnimationTone.ControlLoop(this))
                    {
                        break;
                    }

                    client.SetParameter("AnimationClip", rcas.AnimationClipName, rcas.ProductVersion);
                    client.RequestState("x", "Animate");
                    client.RequestState(false, "x", "Enter");
                }
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
            }
            return(false);
        }
Ejemplo n.º 5
0
        public static bool StateMachineEnterAndSit(SittableComponent ths, StateMachineClient smc, SittingPosture sitPosture, Slot routingSlot, object sitContext)
        {
            if ((smc == null) || (sitPosture == null))
            {
                return(false);
            }

            SitData target     = sitPosture.Part.Target;
            bool    paramValue = (ths.Owner.BoobyTrapComponent != null) ? ths.Owner.BoobyTrapComponent.CanTriggerTrap(sitPosture.Sim.SimDescription) : false;

            smc.SetParameter("isBoobyTrapped", paramValue);
            smc.SetParameter("sitTemplateSuffix", target.IKSuffix);
            smc.EnterState("x", ths.GetEnterStateName(routingSlot));
            smc.RequestState("x", ths.GetSitStateName());

            if (paramValue)
            {
                (ths.Owner as IBoobyTrap).TriggerTrap(sitPosture.Sim);
                smc.SetParameter("isBoobyTrapped", false);
            }

            ths.TurnOnFootDiscouragmentArea(target);
            return(true);
        }
Ejemplo n.º 6
0
        protected override bool Run()
        {
            StateMachineClient client = StateMachineClient.Acquire(base.Actor, "single_animation");

            client.SetActor("x", base.Actor);
            client.EnterState("x", "Enter");
            Definition interactionDefinition = base.InteractionDefinition as Definition;

            if (Sim.AnimationClipDataForCAS.SimCanPlayAnimation(base.Actor, interactionDefinition.ClipName))
            {
                client.SetParameter("AnimationClip", interactionDefinition.ClipName);
                client.RequestState("x", "Animate");
                client.RequestState(false, "x", "Enter");
            }
            return(true);
        }
        protected override bool Run()
        {
            StateMachineClient client = StateMachineClient.Acquire(base.Actor, "single_looping_animation");

            client.SetActor("x", base.Actor);
            client.EnterState("x", "EnterExit");
            Definition interactionDefinition = base.InteractionDefinition as Definition;

            if (Sim.AnimationClipDataForCAS.SimCanPlayAnimation(base.Actor, interactionDefinition.ClipName))
            {
                client.SetParameter("AnimationClip", interactionDefinition.ClipName);
                client.RequestState("x", "Animate");
                base.DoLoop(~(ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));
                client.RequestState("x", "EnterExit");
                return(true);
            }
            return(false);
        }
Ejemplo n.º 8
0
        protected override bool Run()
        {
            StateMachineClient client = StateMachineClient.Acquire(base.Actor, "single_animation");

            client.SetActor("x", base.Actor);
            client.EnterState("x", "Enter");
            Definition interactionDefinition = base.InteractionDefinition as Definition;

            Sim.AnimationClipDataForCAS[] rcasArray = (interactionDefinition.MenuText == "Full Body Animation Suite") ? Sim.AnimationClipDataForCAS.sCasAnimations["CasFullBodyAnimations"] : Sim.AnimationClipDataForCAS.sCasAnimations["CasFaceAnimations"];
            foreach (Sim.AnimationClipDataForCAS rcas in rcasArray)
            {
                if (Sim.AnimationClipDataForCAS.SimCanPlayAnimation(base.Actor, rcas.AnimationClipName))
                {
                    client.SetParameter("AnimationClip", rcas.AnimationClipName);
                    client.RequestState("x", "Animate");
                    client.RequestState(false, "x", "Enter");
                }
            }
            return(true);
        }
Ejemplo n.º 9
0
        public static StateMachineClient CreateStateMachine(Sim s, HarvestPlant p, out Soil dummyIk)
        {
            dummyIk = Soil.Create(isDummyIk: true);
            StateMachineClient val = StateMachineClient.Acquire(s, "petgardening");

            //dummyIk.SetHiddenFlags(HiddenFlags.Nothing);
            dummyIk.SetPosition(p.GetSoil().Position);
            Vector3 forward = p.GetSoil().Position - s.Position;

            dummyIk.SetForward(forward);
            dummyIk.AddToWorld();
            val.SetActor("x", s);
            val.SetActor("gardenPlantBush", p);
            val.SetActor("gardenSoil", p.GetSoil());
            val.SetActor("Dummy", dummyIk);
            if (!p.PlantDef.GetPlantHeight(out PlantHeight height))
            {
                height = PlantHeight.Medium;
            }
            val.SetParameter("Plant Height", height);
            return(val);
        }
Ejemplo n.º 10
0
        public bool BaseRunEx()
        {
            mRelationship = Relationship.Get(Actor, Target, true);
            if (mRelationship == null)
            {
                return(false);
            }
            bool flag = false;

            if (IsSlowDance)
            {
                string reason;
                GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                if (CommonSocials.CanGetRomantic(Actor, Target, false, false, true, ref greyedOutTooltipCallback, out reason))
                {
                    flag = true;
                }
            }
            else
            {
                foreach (CommodityTypes types in kAcceptableCommodities)
                {
                    if (mRelationship.STC.CurrentCommodity == types)
                    {
                        flag = true;
                        break;
                    }
                }
            }

            Definition interactionDefinition = InteractionDefinition as Definition;
            IDanceable danceObject           = interactionDefinition.DanceObject;

            if (flag)
            {
                mDanceFloor = DanceFloor.FindAndRouteOntoADanceFloorWithFollower(Actor, Target, danceObject);
                if (mDanceFloor != null)
                {
                    mDanceFloor.AddToUseList(Actor);
                    if (!mDanceFloor.IsActorUsingMe(Target))
                    {
                        mDanceFloor.AddToUseList(Target);
                    }
                }
            }

            Stereo targetStereo = interactionDefinition.TargetStereo;

            if (targetStereo != null)
            {
                targetStereo.AddSimListener(Actor);
                targetStereo.AddSimListener(Target);
            }

            string         instanceName = "SocialJigTwoPerson";
            ProductVersion baseGame     = ProductVersion.BaseGame;

            if (IsSlowDance)
            {
                instanceName = "SlowdanceJig";
                baseGame     = ProductVersion.EP8;
            }

            SocialJig = GlobalFunctions.CreateObjectOutOfWorld(instanceName, baseGame) as SocialJigTwoPerson;
            bool succeeded = false;

            Actor.SynchronizationLevel  = Sim.SyncLevel.NotStarted;
            Target.SynchronizationLevel = Sim.SyncLevel.NotStarted;
            string name = (Stereo.PartySimIsGettingMusicFromPartyLocation(Actor, danceObject) || Stereo.PartySimIsGettingMusicFromPartyLocation(Target, danceObject)) ? LocalizeString("BeRockingDancingTogether", new object[0x0]) : LocalizeString("BeDancingTogether", new object[0x0]);

            if (BeginSocialInteraction(new SocialInteractionB.Definition(null, name, false), true, false))
            {
                IGlass objectInRightHand = Actor.GetObjectInRightHand() as IGlass;
                if (objectInRightHand != null)
                {
                    objectInRightHand.PutGlassAway();
                }
                objectInRightHand = Target.GetObjectInRightHand() as IGlass;
                if (objectInRightHand != null)
                {
                    objectInRightHand.PutGlassAway();
                }

                string             stateMachineName = IsSlowDance ? "slowdance_together" : "dance_together";
                StateMachineClient smc = StateMachineClient.Acquire(Actor, stateMachineName);
                if (IsSlowDance)
                {
                    smc.SetActor("x", Actor);
                    smc.SetActor("y", Target);
                }
                else
                {
                    smc.SetActor("x", Target);
                    smc.SetActor("y", Actor);
                }
                smc.EnterState("x", "enter");
                smc.EnterState("y", "enter");
                if (GameUtils.IsInstalled(ProductVersion.EP7))
                {
                    smc.SetParameter("xIsProper", Target.HasTrait(TraitNames.Proper));
                    smc.SetParameter("yIsProper", Actor.HasTrait(TraitNames.Proper));
                }
                BeginCommodityUpdates();
                smc.RequestState(false, "x", "Ask_To_Dance");
                smc.RequestState(true, "y", "Ask_To_Dance");
                if (flag)
                {
                    smc.RequestState(false, "x", "Last_Sync");
                    smc.RequestState(true, "y", "Last_Sync");
                    smc.RequestState(false, "x", "dance");
                    smc.RequestState(true, "y", "dance");
                    Actor.SkillManager.StartGainAndAddSkillIfNeeded(SkillNames.Dancing, Stereo.kRateOfSkillGainForDancing);
                    Target.SkillManager.StartGainAndAddSkillIfNeeded(SkillNames.Dancing, Stereo.kRateOfSkillGainForDancing);
                    if (IsSlowDance)
                    {
                        EventTracker.SendEvent(EventTypeId.kSlowDanced, Actor, Target);
                        EventTracker.SendEvent(EventTypeId.kSlowDanced, Target, Actor);
                    }
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), new InteractionInstance.InsideLoopFunction(DanceTogetherDelegate), smc);
                    Actor.SkillManager.StopSkillGain(SkillNames.Dancing);
                    Target.SkillManager.StopSkillGain(SkillNames.Dancing);
                    smc.RequestState(false, "x", "friendly");
                    smc.RequestState(true, "y", "friendly");
                }
                else
                {
                    smc.RequestState(false, "x", "awkward");
                    smc.RequestState(true, "y", "awkward");
                    mRelationship.LTR.UpdateLiking(Stereo.kLtrDecreaseAfterRejectingDanceTogether);
                    succeeded = false;
                }
            }

            Definition definition2 = InteractionDefinition as Definition;

            if ((definition2 != null) && (definition2.DanceObject is DJTurntable))
            {
                EventTracker.SendEvent(EventTypeId.kDanceToDJMusic, Target);
                EventTracker.SendEvent(EventTypeId.kDanceToDJMusic, Actor);
            }

            EndCommodityUpdates(succeeded);
            Actor.ClearSynchronizationData();
            return(succeeded);
        }
Ejemplo n.º 11
0
        public override bool Run()
        {
            try
            {
                BuffInstance element = Actor.BuffManager.GetElement(BuffNames.ReallyHasToPee);
                if ((element != null) && (element.mTimeoutCount <= Toilet.kTimeoutRemainingForBladderEmergency))
                {
                    RequestWalkStyle(Sim.WalkStyle.Run);
                }
                if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.DefaultAllowSubstitution, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), Toilet.kTimeToWaitInLine))
                {
                    return(false);
                }

                if (CanPerformShooPet)
                {
                    if (!Actor.SimRoutingComponent.PreRouteCheckForLine(Target))
                    {
                        return(false);
                    }
                    Sims3.SimIFace.Route r = Actor.CreateRoute();
                    r.PlanToSlot(Target, Slot.RoutingSlot_0);
                    r.RegisterCallback(new RouteCallback(SlotInUse), RouteCallbackType.TriggerOnTrue, RouteCallbackConditions.OnEventType(RouteEvent.tEventType.EventDestinationObstructed));
                    if (!Actor.DoRoute(r))
                    {
                        return(false);
                    }
                    if (Target.InUse)
                    {
                        Actor.AddExitReason(ExitReason.ObjectInUse);
                        return(false);
                    }
                }
                else if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                {
                    return(false);
                }
                ClearRequestedWalkStyles();

                if ((!(Target is ToiletStall)) && (Shooless.Settings.GetPrivacy(Target)))
                {
                    mSituation = Toilet.ToiletSituation.Create(Actor, Actor.LotCurrent);
                }

                if (mSituation != null)
                {
                    if (!mSituation.Start())
                    {
                        return(false);
                    }
                    if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                    {
                        mSituation.ExitToiletSituation();
                        return(false);
                    }
                }

                CancellableByPlayer = false;
                StandardEntry();
                StateMachineClient stateMachine = Target.GetStateMachine(Actor);
                stateMachine.SetParameter("isDirty", Target.Cleanable.NeedsToBeCleaned);
                mCensorEnabled = true;

                OutfitCategories previousCategory = Actor.CurrentOutfitCategory;
                int previousIndex = Actor.CurrentOutfitIndex;

                bool switchOutfit = false;

                Actor.EnableCensor(Sim.CensorType.LowerBody);

                stateMachine.AddOneShotScriptEventHandler(120, TurnOffCensorGrid);
                stateMachine.AddOneShotScriptEventHandler(200, TriggerTrapCallback);
                if (element != null)
                {
                    element.mTimeoutPaused = true;
                }

                if (ShouldSit(Actor))
                {
                    if (Shooless.Settings.mNakedToilet)
                    {
                        Actor.SwitchToOutfitWithSpin(Sim.ClothesChangeReason.GoingToBathe);
                        switchOutfit = true;
                    }

                    Target.PutDownSeat(stateMachine);
                    stateMachine.RequestState("x", "peeSitting");
                    if ((Target.SculptureComponent != null) && (Target.SculptureComponent.Material == SculptureComponent.SculptureMaterial.Ice))
                    {
                        Actor.BuffManager.AddElement(BuffNames.Chilly, Origin.FromSittingOnIce);
                    }
                    if (Target.ToiletTuning.AutoFlushes && RandomUtil.RandomChance((float)Toilet.kChanceOfToiletAutoFlushWhileInUse))
                    {
                        stateMachine.RequestState("x", "flushReaction");
                    }
                }
                else
                {
                    Target.PutUpSeat(stateMachine);
                    stateMachine.RequestState("x", "peeStanding");
                }
                BeginCommodityUpdate(CommodityKind.Bladder, 0f);
                BeginCommodityUpdates();

                bool succeeded = false;

                try
                {
                    Actor.Motives.LerpToFill(this, CommodityKind.Bladder, Toilet.kMaxLengthUseToilet);
                    StartStages();
                    OccultImaginaryFriend.GrantMilestoneBuff(Actor, BuffNames.ImaginaryFriendFeelOfPorcelain, Origin.FromImaginaryFriendFirstTime, true, true, false);
                    succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.BuffFailureState | ExitReason.MaxSkillPointsReached | ExitReason.HigherPriorityNext));
                    Actor.BuffManager.UnpauseBuff(BuffNames.ImaginaryFriendFeelOfPorcelain);
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                if (succeeded)
                {
                    Motive motive = Actor.Motives.GetMotive(CommodityKind.Bladder);
                    if (motive != null)
                    {
                        motive.PotionBladderDecayOverride = false;
                    }
                }

                if (element != null)
                {
                    element.mTimeoutPaused = false;
                }
                Target.Cleanable.DirtyInc(Actor);

                if (Target.ShouldPutDownSeat(Actor))
                {
                    Target.PutDownSeat(stateMachine);
                }

                InteractionInstance instance = null;
                bool flag2 = Target.Line.MemberCount() > 0x1;
                if ((mSituation == null) || !mSituation.SomeoneDidIntrude)
                {
                    if (Target.ToiletTuning.AutoFlushes)
                    {
                        Target.FlushToilet(Actor, stateMachine, false);
                    }
                    else
                    {
                        Target.ToiletVolume++;
                        if (Target.ShouldFlush(Actor, Autonomous))
                        {
                            Target.FlushToilet(Actor, stateMachine, true);
                        }
                    }

                    if (Target.ShouldWashHands(Actor) && !flag2)
                    {
                        Sink target = Toilet.FindClosestSink(Actor);
                        if (target != null)
                        {
                            instance = Sink.WashHands.Singleton.CreateInstance(target, Actor, GetPriority(), false, true);
                        }
                    }
                }

                stateMachine.RequestState("x", "Exit");
                if (mSituation != null)
                {
                    mSituation.ExitToiletSituation();
                }

                if (switchOutfit)
                {
                    Actor.SwitchToOutfitWithSpin(previousCategory, previousIndex);
                }

                if (flag2)
                {
                    PrivacySituation.RouteToAdjacentRoom(Actor);
                }

                StandardExit();
                if (instance != null)
                {
                    Actor.InteractionQueue.PushAsContinuation(instance, false);
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Ejemplo n.º 12
0
        public override bool Run()
        {
            try
            {
                BuffInstance element = Actor.BuffManager.GetElement(BuffNames.ReallyHasToPee);
                if ((element != null) && (element.mTimeoutCount <= UberToilet.kTimeoutRemainingForBladderEmergency))
                {
                    RequestWalkStyle(Sim.WalkStyle.Run);
                }
                else if (!Target.Line.WaitForTurn(this, SimQueue.WaitBehavior.DefaultAllowSubstitution, ~(ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), UberToilet.kTimeToWaitInLine))
                {
                    return(false);
                }
                else if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                {
                    return(false);
                }

                ClearRequestedWalkStyles();

                // Custom
                if (Shooless.Settings.GetPrivacy(Target))
                {
                    mSituation = Toilet.ToiletSituation.Create(Actor, Actor.LotCurrent);
                }

                if (mSituation != null)
                {
                    if (!mSituation.Start())
                    {
                        return(false);
                    }
                    if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                    {
                        mSituation.ExitToiletSituation();
                        return(false);
                    }
                }

                CancellableByPlayer = false;
                StandardEntry();
                StateMachineClient smc = StateMachineClient.Acquire(Actor, "ubertoilet_store");
                smc.AddInterest <TraitNames>(TraitNames.HotHeaded);
                smc.SetActor("x", Actor);
                smc.SetActor("ubertoilet", Target);
                smc.EnterState("x", "Enter");
                smc.SetParameter("isDirty", Target.Cleanable.NeedsToBeCleaned);
                smc.SetParameter("isBroken", Target.Repairable.Broken);
                mCensorEnabled = true;
                Actor.EnableCensor(Sim.CensorType.LowerBody);
                smc.AddOneShotScriptEventHandler(0x78, TurnOffCensorGrid);
                smc.AddOneShotScriptEventHandler(0xc8, TriggerTrapCallback);
                if (element != null)
                {
                    element.mTimeoutPaused = true;
                }

                bool flag = false;
                if (ShouldSit(Actor))
                {
                    flag = true;
                    Target.PutDownSeat(smc);
                    smc.RequestState("x", "peeSitting");
                    if ((Target.SculptureComponent != null) && (Target.SculptureComponent.Material == SculptureComponent.SculptureMaterial.Ice))
                    {
                        Actor.BuffManager.AddElement(BuffNames.Chilly, Origin.FromSittingOnIce);
                    }
                    if (Target.ToiletTuning.AutoFlushes && RandomUtil.RandomChance((float)UberToilet.kChanceOfToiletAutoFlushWhileInUse))
                    {
                        smc.RequestState("x", "flushReaction");
                    }
                }
                else
                {
                    Target.PutUpSeat(smc);
                    smc.RequestState("x", "peeStanding");
                }

                if (!Target.Repairable.Broken && (Target.mToiletOnStatus == UberToilet.ToiletOnStatus.Auto))
                {
                    Target.StartMusic();
                }

                BeginCommodityUpdate(CommodityKind.Bladder, 0f);
                BeginCommodityUpdates();
                Actor.Motives.LerpToFill(this, CommodityKind.Bladder, UberToilet.kMaxLengthUseToilet);
                StartStages();
                OccultImaginaryFriend.GrantMilestoneBuff(Actor, BuffNames.ImaginaryFriendFeelOfPorcelain, Origin.FromImaginaryFriendFirstTime, true, true, false);
                bool succeeded = DoLoop(~(ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.BuffFailureState | ExitReason.MaxSkillPointsReached | ExitReason.HigherPriorityNext));
                Actor.BuffManager.UnpauseBuff(BuffNames.ImaginaryFriendFeelOfPorcelain);
                EndCommodityUpdates(succeeded);
                if (succeeded)
                {
                    Actor.Motives.GetMotive(CommodityKind.Bladder).PotionBladderDecayOverride = false;
                }

                if (element != null)
                {
                    element.mTimeoutPaused = false;
                }

                Target.Cleanable.DirtyInc(Actor);
                if (Target.ShouldPutDownSeat(Actor))
                {
                    Target.PutDownSeat(smc);
                }

                InteractionInstance instance = null;
                bool flag3 = Target.Line.MemberCount() > 0x1;
                if (Target.Repairable.Broken)
                {
                    if (flag)
                    {
                        smc.RequestState("x", "electricBreakSitting");
                    }
                    else
                    {
                        smc.RequestState("x", "electricBreakStanding");
                    }
                }

                if ((mSituation == null) || !mSituation.SomeoneDidIntrude)
                {
                    if (!Target.ToiletTuning.AutoFlushes)
                    {
                        Target.ToiletVolume++;
                        if (Target.ShouldFlush(Actor, Autonomous))
                        {
                            Target.FlushToilet(Actor, smc, true);
                        }
                    }

                    if (Target.ShouldWashHands(Actor) && !flag3)
                    {
                        Sink target = Toilet.FindClosestSink(Actor);
                        if (target != null)
                        {
                            instance = Sink.WashHands.Singleton.CreateInstance(target, Actor, GetPriority(), false, true);
                        }
                    }
                }

                if (Target.mToiletOnStatus == UberToilet.ToiletOnStatus.Auto)
                {
                    Target.StopMusic();
                }

                if (!Target.Repairable.Broken)
                {
                    if (Target.Upgradable.SelfCleaning && Target.mSelfCleanOn)
                    {
                        smc.RequestState("x", "autoClean");
                        Target.Cleanable.ForceClean();
                        Actor.BuffManager.AddElement(BuffNames.Relaxed, Origin.None);
                        Actor.Motives.ChangeValue(CommodityKind.Hygiene, UberToilet.kChanceOfRelaxed);
                    }
                    else if (RandomUtil.RandomChance(UberToilet.kChanceOfRelaxed))
                    {
                        Actor.BuffManager.AddElement(BuffNames.Relaxed, Origin.None);
                    }
                }

                smc.RequestState("x", "Exit");
                if (mSituation != null)
                {
                    mSituation.ExitToiletSituation();
                }

                if (flag3)
                {
                    PrivacySituation.RouteToAdjacentRoom(Actor);
                }

                StandardExit();
                if (instance != null)
                {
                    Actor.InteractionQueue.PushAsContinuation(instance, false);
                }
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Ejemplo n.º 13
0
        public static bool SitDown(HotTubBase ths, Sim s, Slot slot, HotTubSeat seat, Sim.SwitchOutfitHelper switchOutfitHelper, bool isSkinnyDipping, Sim invitedBy, bool isAutonomous)
        {
            bool flag       = isSkinnyDipping;
            bool paramValue = true;

            if ((s.GetCurrentOutfitCategoryFromOutfitInGameObject() == OutfitCategories.Swimwear) && !isSkinnyDipping)
            {
                paramValue = false;
            }

            if ((s.OccultManager.DisallowClothesChange() || (s.GetCurrentOutfitCategoryFromOutfitInGameObject() == OutfitCategories.Singed)) || s.BuffManager.DisallowClothesChange())
            {
                paramValue = false;
            }

            if ((s.Service != null) && (s.Service.ServiceType == ServiceType.GrimReaper))
            {
                paramValue = false;
            }

            if (s.GetCurrentOutfitCategoryFromOutfitInGameObject() == OutfitCategories.Naked)
            {
                flag = false;
            }
            else
            {
                s.RefreshCurrentOutfit(false);
            }

            if (!paramValue)
            {
                flag = false;
            }

            ths.PartComponent.SetSimAtPart(s, slot);
            switchOutfitHelper.Wait(true);
            StateMachineClient smc = StateMachineClient.Acquire(s, "HotTub", AnimationPriority.kAPDefault);

            if (smc == null)
            {
                s.AddExitReason(ExitReason.NullValueFound);
                ths.PartComponent.SetSimAtPart(null, slot);
                switchOutfitHelper.Dispose();
                return(false);
            }

            smc.SetActor("x", s);
            smc.SetActor("hotTub", ths);
            smc.SetParameter("IkSuffix", seat.IKSuffix);
            smc.SetParameter("isMirrored", seat.IsMirrored);
            smc.SetParameter("doClothesSpin", paramValue);
            smc.SetParameter("playLookaround", isSkinnyDipping && ths.IsFirstSkinnyDipper());
            smc.AddOneShotScriptEventHandler(0x67, new SacsEventHandler(ths.TubEntered));
            smc.AddOneShotScriptEventHandler(0xc9, new SacsEventHandler(seat.SlotSimIntoHottub));
            smc.AddPersistentScriptEventHandler(0x69, new SacsEventHandler(seat.UnparentAndUpdateDrinkStatus));
            if (flag)
            {
                smc.AddOneShotScriptEventHandler(0x67, new SacsEventHandler(seat.CreateClothingPile));
            }

            smc.EnterState("x", "Enter");
            switchOutfitHelper.AddScriptEventHandler(smc);
            Glass actor = null;

            seat.DrinkRef = null;
            Glass.CarryingGlassPosture posture = s.Posture as Glass.CarryingGlassPosture;
            if (posture != null)
            {
                actor = posture.ObjectBeingCarried as Glass;
                CarrySystem.ExitCarry(s);
                actor.FadeOut(true);
                actor.UnParent();
                s.PopPosture();
                actor.ParentToSlot(ths, seat.DrinkSlot);
                actor.FadeIn();
                smc.SetActor("drink", actor);
                seat.DrinkRef = actor;
            }

            s.InteractionQueue.CancelAllInteractionsByType(Glass.Drink.Singleton);
            StereoCheap cheap = s.Inventory.Find <StereoCheap>();

            if (((cheap != null) && !ths.IsSlotOccupied(ths.BoomboxSlot)) && s.Inventory.TryToRemove(cheap))
            {
                cheap.SetOpacity(0f, 0f);
                if (cheap.ParentToSlot(ths, ths.BoomboxSlot))
                {
                    cheap.FadeIn(false);
                }
                else
                {
                    cheap.FadeIn(false, 0f);
                    s.Inventory.TryToAdd(cheap);
                }
            }

            smc.SetParameter("hasDrink", actor != null);
            smc.RequestState("x", "Sitting");
            HotTubPosture posture2 = new HotTubPosture(s, ths, smc, seat);

            posture2.InvitedBy          = invitedBy;
            posture2.AutonomouslyChosen = isAutonomous;
            s.Posture = posture2;
            if (!s.Posture.Satisfies(CommodityKind.InHotTub, ths))
            {
                s.AddExitReason(ExitReason.FailedToStart);
                ths.PartComponent.SetSimAtPart(null, slot);
                seat.DrinkRef = null;
                return(false);
            }

            EventTracker.SendEvent(new Event(EventTypeId.kGoHotTubbing, s, ths));
            if (isSkinnyDipping)
            {
                StartSkinnyDipBroadcastersAndSendWishEvents(ths, s);
            }
            return(true);
        }