Ejemplo n.º 1
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.º 2
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.º 3
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.º 4
0
        private bool DoHarvestEx()
        {
            Soil soil;

            Target.RemoveHarvestStateTimeoutAlarm();
            StandardEntry();
            BeginCommodityUpdates();
            StateMachineClient stateMachine = Target.GetStateMachine(Actor, out soil);

            mDummyIk = soil;
            bool hasHarvested = true;

            if (Actor.IsInActiveHousehold)
            {
                hasHarvested = false;
                foreach (SimDescription description in Actor.Household.SimDescriptions)
                {
                    Gardening skill = description.SkillManager.GetSkill <Gardening>(SkillNames.Gardening);
                    if ((skill != null) && skill.HasHarvested())
                    {
                        hasHarvested = true;
                        break;
                    }
                }
            }

            if (stateMachine != null)
            {
                stateMachine.RequestState("x", "Loop Harvest");
            }

            Plant.StartStagesForTendableInteraction(this);
            while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
            {
                if ((ActiveStage != null) && ActiveStage.IsComplete((InteractionInstance)this))
                {
                    Actor.AddExitReason(ExitReason.StageComplete);
                }
            }

            Plant.PauseTendGardenInteractionStage(Actor.CurrentInteraction);
            if (Actor.HasExitReason(ExitReason.StageComplete))
            {
                HarvestPlantEx.DoHarvest(Target, Actor, hasHarvested, mBurglarSituation);
            }

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

            EndCommodityUpdates(true);
            StandardExit();
            Plant.UpdateTendGardenTimeSpent(this, new Plant.UpdateTendGardenTimeSpentDelegate(HarvestPlant.Harvest.SetHarvestTimeSpent));
            return(Actor.HasExitReason(ExitReason.StageComplete));
        }
Ejemplo n.º 5
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.º 6
0
            // Methods
            public override bool Run()
            {
                StateMachineClient smc = StateMachineClient.Acquire(base.Actor, "DeathReactions");

                smc.SetActor("x", base.Actor);
                smc.EnterState("x", "Enter");
                base.BeginCommodityUpdates();
                smc.RequestState("x", "Shocked");
                smc.RequestState("x", "LovedOneLoop");
                smc.RequestState("x", "Exit");
                return(true);
            }
Ejemplo n.º 7
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);
        }
Ejemplo n.º 8
0
        public override bool Run()
        {
            this.mClothingPile = this.Actor.GetObjectInRightHand() as ClothingPileWet;
            if (mClothingPile == null)
            {
                ClothingPileWet closestObject1 = GlobalFunctions.GetClosestObject <ClothingPileWet>((IEnumerable <ClothingPileWet>) this.Target.LotCurrent.GetObjects <ClothingPileWet>(), (IGameObject)this.Target);
                if (closestObject1 != null)
                {
                    this.Actor.InteractionQueue.PushAsContinuation(ClothingPileWet.DryClothesInDryer.Singleton, (IGameObject)closestObject1, true);
                    return(true);
                }
                WashingMachine closestObject2 = GlobalFunctions.GetClosestObject <WashingMachine>((IEnumerable <WashingMachine>) this.Target.LotCurrent.GetObjects <WashingMachine>(), (IGameObject)this.Target, new Predicate <WashingMachine>(WashingMachineDoLaundryEx.IsWashingDone));
                if (closestObject2 != null)
                {
                    this.Actor.InteractionQueue.PushAsContinuation(WashingMachine.DryClothesInDryer.Singleton, (IGameObject)closestObject2, true);
                    return(true);
                }
                return(false);
            }
            if (!this.Target.RouteToDryerAndCheckInUse((InteractionInstance)this) || this.Target.CurDryerState != Dryer.DryerState.Empty)
            {
                CarrySystem.PutDownOnFloor(this.Actor, new SacsEventHandler(this.OnPutdownAnimationEvent), 102U);
                return(false);
            }
            this.StandardEntry();
            this.Target.mDryerStateMachine = StateMachineClient.Acquire((IHasScriptProxy)this.Target, "dryer");
            StateMachineClient dryerStateMachine = this.Target.mDryerStateMachine;

            dryerStateMachine.SetActor("x", (IHasScriptProxy)this.Actor);
            dryerStateMachine.SetActor("clothesBag", (IHasScriptProxy)this.mClothingPile);
            dryerStateMachine.SetActor("dryer", (IHasScriptProxy)this.Target);
            dryerStateMachine.EnterState("x", "Enter");
            dryerStateMachine.EnterState("dryer", "Enter");
            dryerStateMachine.AddPersistentScriptEventHandler(0U, new SacsEventHandler(this.OnAnimationEvent));
            this.BeginCommodityUpdates();
            CarrySystem.ExitAndKeepHolding(this.Actor);
            dryerStateMachine.RequestState(false, "dryer", "Start Dryer");
            dryerStateMachine.RequestState(true, "x", "Start Dryer");
            this.EndCommodityUpdates(true);
            dryerStateMachine.RequestState(false, "dryer", "Loop Operate");
            dryerStateMachine.RequestState(true, "x", "Exit Add Clothes");
            Punishment.ApplyAbsolvingActionToSim(this.Actor, Punishment.AbsolvingActionType.DoingLaundry);
            this.StandardExit();
            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.º 10
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.º 11
0
        public new bool DoHarvest()
        {
            Target.RemoveHarvestStateTimeoutAlarm();
            StandardEntry();
            BeginCommodityUpdates();
            Soil dummyIk;

            // Todo: Fix state machine
            StateMachineClient stateMachine = Target.GetStateMachine(Actor, out dummyIk);

            mDummyIk = dummyIk;
            bool hasHarvested = true;

            if (stateMachine != null)
            {
                stateMachine.RequestState("x", "Loop Harvest");
            }
            Plant.StartStagesForTendableInteraction(this);
            while (!Actor.WaitForExitReason(Sim.kWaitForExitReasonDefaultTime, ExitReason.Default))
            {
                if (base.ActiveStage != null && base.ActiveStage.IsComplete((InteractionInstance)this))
                {
                    Actor.AddExitReason(ExitReason.StageComplete);
                }
            }
            Plant.PauseTendGardenInteractionStage(Actor.CurrentInteraction);
            if (Actor.HasExitReason(ExitReason.StageComplete))
            {
                Target.DoHarvest(Actor, hasHarvested, mBurglarSituation);
            }
            if (stateMachine != null)
            {
                stateMachine.RequestState("x", "Exit Standing");
            }
            EndCommodityUpdates(succeeded: true);
            StandardExit();
            Plant.UpdateTendGardenTimeSpent(this, SetHarvestTimeSpent);
            return(Actor.HasExitReason(ExitReason.StageComplete));
        }
Ejemplo n.º 12
0
        private bool StartCookingProcessWithFoodTray(string menuText, string[] menuPath, Recipe.MealDestination destination, Recipe.MealQuantity quantity, Recipe.MealRepetition repetition)
        {
            List <Ingredient> ingredientsUsed = new List <Ingredient>();

            if (!this.Actor.IsNPC && !AniRecipe.UseUpIngredientsFrom(this.ChosenRecipe, this.Actor, ref ingredientsUsed, quantity, false))
            {
                return(false);
            }
            this.Actor.SkillManager.AddElement(SkillNames.Cooking);
            FoodTray foodTray = (FoodTray)GlobalFunctions.CreateObject("FoodTray", Vector3.OutOfWorld, 0, Vector3.UnitZ);

            foodTray.CookingProcess = new CookingProcess(this.ChosenRecipe, ingredientsUsed, this.Target, this.Target.LotCurrent, destination, quantity, repetition, menuText, menuPath, foodTray, this.Actor);
            foodTray.CreateFoodProp(Slots.Hash("Slot_0"), foodTray.CookingProcess.Recipe.ModelsAndMaterials.GrillModel_FoodTray);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            CookingProcess.MoveToNextStep(foodTray, this.Actor);
            StateMachineClient stateMachineClient = StateMachineClient.Acquire(this.Actor.Proxy.ObjectId, "Grill");

            if (stateMachineClient == null)
            {
                return(false);
            }
            stateMachineClient.AddInterest <TraitNames>(TraitNames.Clumsy);
            stateMachineClient.SetActor("x", this.Actor);
            stateMachineClient.SetActor("FoodTray", foodTray);
            stateMachineClient.EnterState("x", "Enter - Hands Empty");
            stateMachineClient.RequestState("x", "Take Out Food Tray");
            stateMachineClient.RequestState("x", "Exit - Holding Food Tray");
            if (this.Actor.HasExitReason(ExitReason.Canceled))
            {
                CarrySystem.EnterWhileHolding(this.Actor, foodTray);
                Food.PutHeldObjectDownOnCounterTableOrFloor(this.Actor, SurfaceType.Normal);
                return(false);
            }
            CarrySystem.EnterWhileHolding(this.Actor, foodTray);
            InteractionInstance instance = FoodTray_Prepare.Singleton.CreateInstance(foodTray, this.Actor, this.Actor.InheritedPriority(), base.Autonomous, true);

            return(this.Actor.InteractionQueue.PushAsContinuation(instance, true));
        }
Ejemplo n.º 13
0
        private bool AbductSim()
        {
            if (!StartSync(true))
            {
                return(false);
            }

            Target.SetPosition(mJig.Position);
            Target.SetForward(mJig.ForwardVector);
            mPreAbductFX = VisualEffect.Create("ep8UfoCloaked");
            mPreAbductFX.SetPosAndOrient(Target.Position, Target.ForwardVector, Target.UpVector);
            mPreAbductFX.Start();
            Actor.SynchronizationLevel = Sim.SyncLevel.Routed;

            if (!Actor.WaitForSynchronizationLevelWithSim(SimToAbduct, Sim.SyncLevel.Routed, 60f))
            {
                FinishLinkedInteraction(true);
                return(false);
            }

            StateMachineClient mCurrentStateMachine = LinkedInteractionInstance.mCurrentStateMachine;

            mCurrentStateMachine.SetActor("x", Actor);
            mCurrentStateMachine.SetActor("UFO", Target);
            mCurrentStateMachine.EnterState("x", "Enter Abducter");
            mCurrentStateMachine.EnterState("UFO", "Enter Abducter");
            mCurrentStateMachine.AddOneShotScriptEventHandler(100u, new SacsEventHandler(OnAnimationEvent));
            mCurrentStateMachine.AddOneShotScriptEventHandler(101u, new SacsEventHandler(OnAnimationEvent));
            mCurrentStateMachine.AddOneShotScriptEventHandler(102u, new SacsEventHandler(OnAnimationEvent));
            mCurrentStateMachine.RequestState(false, "UFO", "UFO idle");
            mCurrentStateMachine.RequestState(true, "x", "UFO idle");
            DoTimedLoop(CarUFO.kAbductUFOHoverTime, ExitReason.None);
            mCurrentStateMachine.RequestState(false, "UFO", "Exit Abduct");
            mCurrentStateMachine.RequestState(false, "y", "Exit Abduct");
            mCurrentStateMachine.RequestState(true, "x", "Exit Abduct");

            return(true);
        }
Ejemplo n.º 14
0
        public override bool Run()
        {
            List <ObjectListPickerInfo> Entries = ListExpressions();
            string text = (string)ObjectListPickerDialog.Show("Expression", Entries);

            if (text != null && text != "")
            {
                ReactionTypes reaction = (ReactionTypes)Enum.Parse(typeof(ReactionTypes), text);

                Array             reactionTypes = Enum.GetValues(typeof(ReactionTypes));
                CustomOverlayData data          = null;
                CmoPoseBox        box           = PoseManager.FindPoseBox();
                string            poseData      = PoseManager.GetCurrentPose(Actor);
                if (poseData == null)
                {
                    return(false);
                }
                Actor.LookAtManager.DisableLookAts();
                PoseManager.SetCurrentPose(Actor, poseData);
                box.PlaySoloAnimation(Actor.SimDescription.IsHuman, Actor, poseData, true, ProductVersion.BaseGame);
                Actor.ResetAllAnimation();
                Actor.OverlayComponent.UpdateInteractionFreeParts(AwarenessLevel.OverlayFace);//OverlayUpperbody);
                StateMachineClient stateMachineClient = StateMachineClient.Acquire(Actor.ObjectId, "facial_idle", AnimationPriority.kAPDefault, true);
                data = (CustomOverlayData)OverlayComponent.GetOverlayData(reaction, Actor);


                stateMachineClient.UseActorBridgeOrigins = false;
                stateMachineClient.SetActor("x", Actor);
                stateMachineClient.RemoveEventHandler(new SacsEventHandler(Actor.OverlayComponent.InteractionPartLevelCallback));
                stateMachineClient.RemoveEventHandler(new SacsEventHandler(Actor.OverlayComponent.ClearInteractionPartLevelCallback));
                stateMachineClient.EnterState("x", "Enter");
                stateMachineClient.SetProductVersion(data.ProductVersion);
                stateMachineClient.RequestState("x", data.AnimClipName);
                //Actor.OverlayComponent.UpdateInteractionFreeParts(AwarenessLevel.OverlayFace);

                box.PlaySoloAnimation(Actor.SimDescription.IsHuman, Actor, poseData, true, ProductVersion.BaseGame);
                Actor.ResetAllAnimation();

                Actor.WaitForExitReason(3.40282347E+38f, ExitReason.UserCanceled);
                Actor.LookAtManager.EnableLookAts();
                return(true);
            }
            return(false);
        }
Ejemplo n.º 15
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.º 16
0
        public override bool OnPortalStart(Sim sim)
        {
            try
            {
                if ((mCurrentlyRoutingSim != null) && (mCurrentlyRoutingSim.HasBeenDestroyed))
                {
                    if (mSMC != null)
                    {
                        mSMC.Dispose();
                        mSMC = null;
                    }
                }

                mCurrentlyRoutingSim = sim;

                if (mSMC != null)
                {
                    sim.PlayRouteFailure(mPortal);
                    return(false);
                }

                AncientPortal targetPortal = null;
                if (!sTargetPortals.TryGetValue(sim, out targetPortal))
                {
                    sim.PlayRouteFailure(mPortal);
                    return(false);
                }

                if (targetPortal == mPortal)
                {
                    return(false);
                }

                mPortal.AddToUseList(sim);

                sim.SimRoutingComponent.OnRouteActionsFinished -= OnPortalApproachCancelledAndFinished;
                sim.SetExitReasonsInterruptForMultiPortalRoute();
                sim.SimRoutingComponent.StartIgnoringObstacles();

                targetPortal.AddToUseList(sim);

                targetPortal.EnableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash);
                targetPortal.PushSimsFromFootprint(AncientPortal.CatchABeam.FootprintPlacementHash, sim, null, false);

                Vector3 slotFoward = mPortal.GetForwardOfSlot(mPortal.GetRoutingSlots()[0]);

                sim.SetForward(slotFoward);

                mSMC = StateMachineClient.Acquire(sim, "AncientPortal", AnimationPriority.kAPDefault);
                mSMC.SetActor("x", sim);
                mSMC.SetActor("portal", mPortal);
                mSMC.EnterState("x", "Enter");
                mSMC.EnterState("portal", "Enter");

                mSMC.AddOneShotScriptEventHandler(0x65, HideSim);
                mSMC.AddOneShotScriptEventHandler(0x66, ShowSim);

                mSMC.RequestState("x", "InsidePortal");

                mPortal.RemoveFromUseList(sim);

                return(true);
            }
            catch (ResetException)
            {
                if (mCurrentlyRoutingSim != null)
                {
                    mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing);
                }

                throw;
            }
            catch (Exception e)
            {
                if (mCurrentlyRoutingSim != null)
                {
                    mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing);
                }

                Common.Exception(sim, Owner, e);
                return(false);
            }
        }
Ejemplo n.º 17
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteToCan(Actor, true))
                {
                    return(false);
                }
                StateMachineClient stateMachine = Target.GetStateMachine(Actor, false);
                stateMachine.AddOneShotScriptEventHandler(0x65, Target.EventCallbackRemoveLid);
                stateMachine.AddOneShotScriptEventHandler(0x66, Target.EventCallbackAddLid);

                Trashcan target = Target as Trashcan;
                if (target != null)
                {
                    mLidGuid = target.SetupLidProp(stateMachine);
                }

                IFairyBoobyTrap trap = Target as IFairyBoobyTrap;
                if (((trap != null) && ((trap.BoobyTrapComponent != null) ? trap.BoobyTrapComponent.CanTriggerTrap(Actor.SimDescription) : false)) && trap.TriggerTrap(Actor))
                {
                    TrashcanOutside outsideCan = Target as TrashcanOutside;
                    if (outsideCan != null)
                    {
                        TrashPile.CreateFairyTrapTrashPiles(outsideCan);
                    }
                    return(false);
                }

                StandardEntry();
                BeginCommodityUpdates();

                try
                {
                    if (!Autonomous)
                    {
                        Target.HasBeenRummagedByPlayer = true;
                    }
                    Target.SetRummagingSim(Actor);
                    Target.RummageBroadcasterCreate();
                    stateMachine.RequestState("x", "LoopRummage");
                    if ((!Autonomous && (HudController.InfoState != InfoState.Inventory)) && Actor.IsActiveSim)
                    {
                        HudController.SetInfoState(InfoState.Inventory);
                    }
                    mNetWorth = Target.LotCurrent.Household.NetWorth();
                    DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), LoopDel, stateMachine);
                    Target.RummageBroadcasterDestroy();
                    stateMachine.RequestState("x", "Exit");
                    if (!Autonomous)
                    {
                        HudModel.OpenObjectInventoryForOwner(null);
                    }
                }
                finally
                {
                    EndCommodityUpdates(true);
                }

                BuffInstance element = Actor.BuffManager.GetElement(BuffNames.Smelly);
                if (element != null)
                {
                    element.mBuffOrigin = Origin.FromDumpsterDiving;
                }
                StandardExit();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Ejemplo n.º 18
0
        public override bool Run()
        {
            bool result = false;

            try
            {
                ProxyDefinition proxyDefinition = base.InteractionDefinition as ProxyDefinition;
                Vector3         slotPosition    = Target.GetSlotPosition(Slot.RoutingSlot_0);
                if (Actor == WooHooer && !Actor.HasExitReason())
                {
                    if (!Target.SimLine.WaitForTurn(this, Actor, SimQueue.WaitBehavior.CutAheadOfLowerPrioritySims, ExitReason.Default, Toilet.kTimeToWaitInLine))
                    {
                        return(result);
                    }
                    //float value1 = Actor.Motives.GetMotiveValue(CommodityKind.Bladder);
                    //float value2 = WooHooee.Motives.GetMotiveValue(CommodityKind.Bladder);
                    isSitting = (Actor.Position - slotPosition).Length() < (WooHooee.Position - slotPosition).Length();                     //(value1 < Math.Min(0, value2)) || (value2 >= 0 && RandomUtil.CoinFlip());
                    ToiletStallWooHoo wooHoo = proxyDefinition.ProxyClone(WooHooee).CreateInstance(Target, WooHooee, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true) as ToiletStallWooHoo;
                    wooHoo.LinkedInteractionInstance = this;
                    wooHoo.WooHooer  = WooHooer;
                    wooHoo.WooHooee  = WooHooee;
                    wooHoo.isSitting = !isSitting;
                    WooHooee.InteractionQueue.AddNext(wooHoo);
                }
                if (base.StartSync(!isSitting))
                {
                    if (!isSitting)
                    {
                        Actor.RouteToPointRadius(slotPosition, 1f);
                    }
                    if ((isSitting || Actor.WaitForSynchronizationLevelWithSim(LinkedInteractionInstance.InstanceActor, Sim.SyncLevel.Routed, 30f)) && Actor.RouteToSlot(Target, Slot.RoutingSlot_0))
                    {
                        Actor.SynchronizationLevel = Sim.SyncLevel.Routed;
                        base.StandardEntry();
                        StateMachineClient stateMachine = Target.GetStateMachine(Actor);

                        if (SitDownAndWait(stateMachine))
                        {
                            BuffInstance element = Actor.BuffManager.GetElement(BuffNames.ReallyHasToPee);
                            if (element != null)
                            {
                                element.mTimeoutPaused = true;
                            }
                            base.BeginCommodityUpdates();
                            isWooHooing = !proxyDefinition.Makeout;
                            bool skipFlush = false;
                            if (isSitting)
                            {
                                Actor.EnableCensor(Sim.CensorType.FullHeight);
                                base.FinishLinkedInteraction(false);
                                skipFlush = !RelieveSelf(element);
                                base.WaitForSyncComplete();
                                Actor.AutoEnableCensor();
                                Actor.BuffManager.UnpauseBuff(BuffNames.ImaginaryFriendFeelOfPorcelain);
                            }
                            else
                            {
                                string stateName = RandomUtil.GetRandomStringFromList(new string[] { "peeStanding", "clean" });
                                stateMachine.RequestState("x", stateName);
                                Actor.EnableCensor(Sim.CensorType.FullHeight);
                                TurnOnWooHooFx();
                                base.DoTimedLoop(RandomUtil.RandomFloatGaussianDistribution(5f, isWooHooing ? 15f : 10f));
                                if (!isWooHooing)
                                {
                                    EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, WooHooer, WooHooee, "Make Out", false, true, false, CommodityTypes.Undefined));
                                    EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, WooHooee, WooHooer, "Make Out", true, true, false, CommodityTypes.Undefined));
                                }
                                else
                                {
                                    EventTracker.SendEvent(EventTypeId.kWooHooed, WooHooer, Target);
                                    EventTracker.SendEvent(EventTypeId.kWooHooed, WooHooee, Target);
                                    CommonWoohoo.RunPostWoohoo(WooHooer, WooHooee, Target, proxyDefinition.GetStyle(this), proxyDefinition.GetLocation(Target), true);
                                    if (CommonPregnancy.IsSuccess(WooHooer, WooHooee, base.Autonomous, proxyDefinition.GetStyle(this)))
                                    {
                                        CommonPregnancy.Impregnate(WooHooer, WooHooee, base.Autonomous, proxyDefinition.GetStyle(this));
                                    }
                                    WooHooer.BuffManager.AddElement(BuffNames.PublicWooHoo, Origin.FromWooHooInPublic);
                                    WooHooee.BuffManager.AddElement(BuffNames.PublicWooHoo, Origin.FromWooHooInPublic);
                                }
                                if (stateName == "clean")
                                {
                                    stateMachine.RequestState("x", "putDown");
                                }
                                RelieveSelf(element);
                                base.EndCommodityUpdates(true);
                                LinkedInteractionInstance.EndCommodityUpdates(true);
                            }
                            isWooHooing = false;
                            Target.Cleanable.DirtyInc(Actor);
                            bool autoFlush = !isSitting || Target.ToiletTuning.AutoFlushes;
                            if (autoFlush || (!skipFlush && Target.ShouldFlush(Actor, base.Autonomous)))
                            {
                                Target.FlushToilet(Actor, stateMachine, !autoFlush);
                            }
                            if (Target.ShouldWashHands(Actor))
                            {
                                Sink sink = Toilet.FindClosestSink(Actor);
                                if (sink != null)
                                {
                                    InteractionInstance interactionInstance = Sink.WashHands.Singleton.CreateInstance(sink, Actor, base.GetPriority(), false, true);
                                    Actor.InteractionQueue.PushAsContinuation(interactionInstance, false);
                                }
                            }
                            result = true;
                        }
                        TurnOffCensorsAndFx();
                        stateMachine.RequestState("x", "Exit");
                        if (!isSitting)
                        {
                            base.FinishLinkedInteraction(true);
                            if (result)
                            {
                                Relationship.Get(WooHooer, WooHooee, true).LTR.UpdateLiking(AllInOneBathroom.kLTRGainFromWoohooInAllInOneBathroom);
                            }
                            Actor.RouteAway(1f, 2f, false, new InteractionPriority(InteractionPriorityLevel.UserDirected), true, false, true, RouteDistancePreference.PreferFurthestFromRouteOrigin);
                        }
                        base.StandardExit();
                    }
                }
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                result = false;
            }
            return(result);
        }
Ejemplo n.º 19
0
        public override bool OnPortalStart(Sim sim)
        {
            try
            {
                if ((mCurrentlyRoutingSim != null) && (mCurrentlyRoutingSim.HasBeenDestroyed))
                {
                    if (mSMC != null)
                    {
                        mSMC.Dispose();
                        mSMC = null;
                    }
                }

                mCurrentlyRoutingSim = sim;

                if (mSMC != null)
                {
                    sim.PlayRouteFailure(mPortal);
                    return false;
                }

                AncientPortal targetPortal = null;
                if (!sTargetPortals.TryGetValue(sim, out targetPortal))
                {
                    sim.PlayRouteFailure(mPortal);
                    return false;
                }

                if (targetPortal == mPortal)
                {
                    return false;
                }

                mPortal.AddToUseList(sim);

                sim.SimRoutingComponent.OnRouteActionsFinished -= OnPortalApproachCancelledAndFinished;
                sim.SetExitReasonsInterruptForMultiPortalRoute();
                sim.SimRoutingComponent.StartIgnoringObstacles();

                targetPortal.AddToUseList(sim);

                targetPortal.EnableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash);
                targetPortal.PushSimsFromFootprint(AncientPortal.CatchABeam.FootprintPlacementHash, sim, null, false);

                Vector3 slotFoward = mPortal.GetForwardOfSlot(mPortal.GetRoutingSlots()[0]);

                sim.SetForward(slotFoward);

                mSMC = StateMachineClient.Acquire(sim, "AncientPortal", AnimationPriority.kAPDefault);
                mSMC.SetActor("x", sim);
                mSMC.SetActor("portal", mPortal);
                mSMC.EnterState("x", "Enter");
                mSMC.EnterState("portal", "Enter");

                mSMC.AddOneShotScriptEventHandler(0x65, HideSim);
                mSMC.AddOneShotScriptEventHandler(0x66, ShowSim);

                mSMC.RequestState("x", "InsidePortal");

                mPortal.RemoveFromUseList(sim);

                return true;
            }
            catch (ResetException)
            {
                if (mCurrentlyRoutingSim != null)
                {
                    mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing);
                }

                throw;
            }
            catch (Exception e)
            {
                if (mCurrentlyRoutingSim != null)
                {
                    mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing);
                }

                Common.Exception(sim, Owner, e);
                return false;
            }
        }
Ejemplo n.º 20
0
            /*
             * [Tunable]
             * [TunableComment("Range: Fun/Stress motive amount.  Description:  Amount of stress that a Sim gets when seeing another Sim die.")]
             * public static float kWitnessDeathStressPenalty = -50f;
             *
             * [Tunable]
             * [TunableComment("Range: Float multiplier.  Description:  Multiplier on additional stress when a family member of loved one sees a Sim die.")]
             * public static float kWitnessDeathRelationshipMultiplier = 1.5f;
             *
             * [TunableComment("Range: Fun/Stress motive amount.  Description:  Amount of fun that a Sim gets when seeing an enemy Sim die.")]
             * [Tunable]
             * public static float kWitnessEnemyDeathFunGain = 50f;
             *
             */



            public override bool Run()
            {
                SwimmingInPool swimmingInPool = Actor.Posture as SwimmingInPool;

                if (swimmingInPool != null && !swimmingInPool.ContainerPool.RouteToEdge(Actor))
                {
                    return(false);
                }
                SwimmingInPool swimmingInPool2 = Target.Posture as SwimmingInPool;

                if (swimmingInPool2 != null)
                {
                    if (!swimmingInPool2.ContainerPool.RouteToEdge(Actor))
                    {
                        return(false);
                    }
                    Actor.RouteTurnToFace(Target.Position);
                }

                else if (!GlobalFunctions.ObjectsWithinRadiusOfEachOther(Actor, Target, 2f))
                {
                    if (Actor == null || Target == null || Target.LotCurrent == null)
                    {
                        return(false);
                    }

                    Route route = Actor.CreateRoute();
                    if (route == null)
                    {
                        return(false);
                    }

                    RequestWalkStyle(Sim.WalkStyle.Run);

                    route.PlanToPointRadialRange(Target.Position, 2f, 6f, RouteDistancePreference.PreferNearestToRouteDestination, RouteOrientationPreference.TowardsObject, Target.LotCurrent.LotId, new int[1]
                    {
                        Target.RoomId
                    });

                    if (Actor == null || !Actor.DoRoute(route))
                    {
                        return(false);
                    }
                    UnrequestWalkStyle(Sim.WalkStyle.Run);
                }
                else
                {
                    Actor.RouteTurnToFace(Target.Position);
                }
                if (Simulator.CheckYieldingContext(false))
                {
                    Simulator.Sleep(20);
                }
                if (Target.SimDescription == null || !Target.SimDescription.IsValidDescription)
                {
                    return(true);
                }
                NFinalizeDeath.CheckYieldingContext();
                StateMachineClient stateMachineClient = StateMachineClient.Acquire(Actor, "DeathReactions");

                stateMachineClient.SetActor("x", Actor);
                stateMachineClient.EnterState("x", "Enter");
                BeginCommodityUpdates();
                bool flag  = false;
                bool flag2 = false;

                //bool flag3 = false;

                LTRData.RelationshipClassification relationshipClassification = LTRData.RelationshipClassification.Low;
                Relationship relationship = Relationship.Get(Actor, Target, false);

                if (relationship != null)
                {
                    relationshipClassification = LTRData.Get(relationship.LTR.CurrentLTR).RelationshipClass;
                }

                if (Actor == null || Target == null || Actor.Genealogy == null || Target.Genealogy == null)
                {
                    return(true);
                }

                if (relationshipClassification == LTRData.RelationshipClassification.High || Actor.Genealogy.IsBloodRelated(Target.Genealogy))
                {
                    if (relationship != null && relationship.AreRomantic() && relationship.LTR.IsPositive)
                    {
                        flag2 = true;
                    }
                    else
                    {
                        flag = true;
                    }
                    //flag3 = true;
                }
                NFinalizeDeath.CheckYieldingContext();
                switch (Actor.SimDescription.Species)
                {
                case CASAgeGenderFlags.None:
                case CASAgeGenderFlags.Human:
                    if (!Actor.IsInActiveHousehold)
                    {
                        stateMachineClient.RequestState("x", "Shocked");
                        NFinalizeDeath.CheckYieldingContext();
                        if (RandomUtil.RandomChance(25))
                        {
                            stateMachineClient.RequestState("x", "Evil");
                        }
                        else
                        {
                            stateMachineClient.RequestState("x", "LovedOneLoop");
                        }
                        flag  = true;
                        flag2 = true;
                        //flag3 = true;
                    }
                    else
                    {
                        stateMachineClient.RequestState("x", "Shocked");
                        NFinalizeDeath.CheckYieldingContext();
                        Actor.Motives.ChangeValue(CommodityKind.Fun, kWitnessDeathStressPenalty);
                        stateMachineClient.RequestState("x", "BasicLoop");
                        flag  = false;
                        flag2 = false;
                        //flag3 = false;
                    }

                    break;

                case CASAgeGenderFlags.Dog:
                case CASAgeGenderFlags.LittleDog:
                    stateMachineClient.RequestState("x", "Dog");
                    break;

                case CASAgeGenderFlags.Cat:
                    stateMachineClient.RequestState("x", "Cat");
                    break;

                case CASAgeGenderFlags.Horse:
                    stateMachineClient.RequestState("x", "Horse");
                    break;
                }
                EventTracker.SendEvent(EventTypeId.kSawSimDie, Actor, Target);
                DoLoop(ExitReason.Default, __LoopDel, stateMachineClient);
                EndCommodityUpdates(true);
                if (Actor.IsInActiveHousehold)
                {
                    if (Actor.BuffManager == null)
                    {
                        return(false);
                    }

                    if (flag2 && Target.SimDescription.DeathStyle != 0)
                    {
                        Actor.BuffManager.AddElement(BuffNames.HeartBroken, Origin.FromWitnessingDeath);
                        BuffHeartBroken.BuffInstanceHeartBroken buffInstanceHeartBroken = Actor.BuffManager.GetElement(BuffNames.HeartBroken) as BuffHeartBroken.BuffInstanceHeartBroken;
                        if (buffInstanceHeartBroken != null)
                        {
                            buffInstanceHeartBroken.MissedSim = Target.SimDescription;
                        }
                    }
                    else if (flag && Target.SimDescription.DeathStyle != 0)
                    {
                        Actor.BuffManager.AddElement(BuffNames.Mourning, Urnstone.CalculateMourningMoodStrength(Actor, Target.SimDescription), Origin.FromWitnessingDeath);
                        BuffMourning.BuffInstanceMourning buffInstanceMourning = Actor.BuffManager.GetElement(BuffNames.Mourning) as BuffMourning.BuffInstanceMourning;
                        if (buffInstanceMourning != null)
                        {
                            buffInstanceMourning.MissedSim = Target.SimDescription;
                        }
                    }
                }
                else
                {
                    if (Actor.BuffManager == null)
                    {
                        return(false);
                    }
                    if (flag2)
                    {
                        Actor.BuffManager.AddElement(BuffNames.HeartBroken, Origin.FromWitnessingDeath);
                        BuffHeartBroken.BuffInstanceHeartBroken buffInstanceHeartBroken = Actor.BuffManager.GetElement(BuffNames.HeartBroken) as BuffHeartBroken.BuffInstanceHeartBroken;
                        if (buffInstanceHeartBroken != null)
                        {
                            buffInstanceHeartBroken.MissedSim = Target.SimDescription;
                        }
                    }
                    else if (flag)
                    {
                        Actor.BuffManager.AddElement(BuffNames.Mourning, Urnstone.CalculateMourningMoodStrength(Actor, Target.SimDescription), Origin.FromWitnessingDeath);
                        BuffMourning.BuffInstanceMourning buffInstanceMourning = Actor.BuffManager.GetElement(BuffNames.Mourning) as BuffMourning.BuffInstanceMourning;
                        if (buffInstanceMourning != null)
                        {
                            buffInstanceMourning.MissedSim = Target.SimDescription;
                        }
                    }
                }
                NFinalizeDeath.CheckYieldingContext();
                stateMachineClient.RequestState("x", "Exit");
                stateMachineClient.Dispose();
                //if (!NFinalizeDeath.IsAllActiveHousehold_SimObject(Actor) &&
                //        !NFinalizeDeath.IsAllActiveHousehold_SimObject(Target) &&
                //        !(Actor.SimDescription.Service is GrimReaper) &&
                //        !(Target.SimDescription.Service is GrimReaper) &&
                //        RandomUtil.RandomChance(70)
                //)
                //return NFinalizeDeath.ForceNHSReapSoul(Target, Actor);

                return(true);
            }
Ejemplo n.º 21
0
            private bool Route()
            {
                Slot slot;
                // Sim sim;
                BedData partContaining = base.Target.GetPartContaining(base.Actor);

                if (partContaining != null)
                {
                    //if (base.Actor.Posture is SleepingPosture)
                    if (base.Actor.Posture.Satisfies(CommodityKind.Sleeping, null))
                    {
                        StateMachineClient stateMachine = partContaining.StateMachine;
                        if (stateMachine != null)
                        {
                            stateMachine.RequestState("x", "ExitRelax");
                            partContaining.StateMachine = null;
                        }
                        partContaining.BedMade = true;
                    }
                    this.mEntryStateName = "Enter_OnBed_" + partContaining.StateNameSuffix;
                    this.mEntryPart      = partContaining;
                    return(true);
                }
                if (base.Target.SimLine != null)
                {
                    ExitReason exitReasons = ~(ExitReason.MidRoutePushRequested | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached);
                    if (!base.Target.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, exitReasons, 30f) || base.Actor.HasExitReason(exitReasons))
                    {
                        return(false);
                    }
                    this.mbInLine = true;
                }
                PartData        partClosestToHit = base.GetPartClosestToHit();
                List <PartData> parts            = new List <PartData>();

                foreach (PartData data3 in base.Target.PartComp.PartDataList.Values)
                {
                    parts.Add(data3);
                }
                if (!base.Actor.RouteToUnusedPart(parts, partClosestToHit, out slot))
                {
                    return(false);
                }
                BedData entryPart = null;

                // Label_017C:
                foreach (BedData data5 in base.Target.PartComp.PartDataList.Values)
                {
                    for (int i = 0; i < data5.RoutingSlot.Length; i++)
                    {
                        if ((data5.RoutingSlot[i] == slot) && !data5.InUse)
                        {
                            entryPart = data5;
                        }
                    }
                }
                if (!base.Target.SetContainedObject(entryPart, base.Actor))
                {
                    base.Actor.AddExitReason(ExitReason.FailedToStart);
                    return(false);
                }
                this.mEntryStateName = "Enter_BedRelax_" + entryPart.StateNameSuffix;
                this.mEntryPart      = entryPart;
                return(true);
            }
Ejemplo n.º 22
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.º 23
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.º 24
0
        public override bool Run()
        {
            try
            {
                if (!Target.RouteSimToMeAndCheckInUse(Actor) || !HarvestPlant.HarvestTest(Target, Actor))
                {
                    return(false);
                }

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

                bool allowChild = false;

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

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

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

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

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

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

                EndCommodityUpdates(true);
                StandardExit();
                Target.RemoveFromWorld();
                Target.Destroy();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
Ejemplo n.º 25
0
        public override bool OnPortalStop(Sim sim)
        {
            try
            {
                AncientPortal targetPortal = null;
                if (!sTargetPortals.TryGetValue(sim, out targetPortal))
                {
                    sim.PlayRouteFailure(mPortal);
                    return(false);
                }

                mSMC.SetActor("portal", targetPortal);

                Slot    slotName       = targetPortal.GetRoutingSlots()[0x0];
                Vector3 positionOfSlot = targetPortal.GetPositionOfSlot(slotName);
                Vector3 forwardOfSlot  = targetPortal.GetForwardOfSlot(slotName);
                sim.SetPosition(positionOfSlot);
                sim.SetForward(forwardOfSlot);

                targetPortal.DisableFootprint(AncientPortal.CatchABeam.FootprintPlacementHash);

                mSMC.RequestState("x", "Exit");

                if (SimTypes.IsSelectable(sim))
                {
                    for (int i = 0x0; i < AncientPortal.CatchABeam.kPotentialTravelBuffs.Length; i++)
                    {
                        if (RandomUtil.RandomChance(AncientPortal.CatchABeam.kChanceForEachBuff))
                        {
                            sim.BuffManager.AddElement(AncientPortal.CatchABeam.kPotentialTravelBuffs[i], Origin.FromAncientPortal);
                        }
                    }
                }

                targetPortal.RemoveFromUseList(sim);

                if (targetPortal.LotCurrent.IsResidentialLot && !sim.IsGreetedOnLot(targetPortal.LotCurrent))
                {
                    sim.GreetSimOnLot(targetPortal.LotCurrent);
                }

                if (mSMC != null)
                {
                    mSMC.Dispose();
                    mSMC = null;
                }

                mCurrentlyRoutingSim = null;

                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(sim, Owner, e);
                return(false);
            }
            finally
            {
                if (mCurrentlyRoutingSim != null)
                {
                    mCurrentlyRoutingSim.SetHiddenFlags(HiddenFlags.Nothing);
                }
            }
        }
Ejemplo n.º 26
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.º 27
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);
        }