Exemplo n.º 1
0
        public override bool Run()
        {
            Common.StringBuilder msg = new Common.StringBuilder("ShowerWoohoo:Run" + Common.NewLine);

            try
            {
                IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

                Actor.BuffManager.RemoveElement(BuffNames.RobotForm);

                mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, Sim.ClothesChangeReason.GoingToBathe);
                mSwitchOutfitHelper.Start();
                if (WaitForBToEnterShower)
                {
                    //Actor.RouteToObjectRadialRange(Shower, 1.5f, 4f);
                    SpeedTrap.Sleep(0xa);
                    while (Shower.SimInShower != Target)
                    {
                        if ((Target.InteractionQueue.GetCurrentInteraction() != TakeShowerInst) || Target.HasExitReason(ExitReason.Canceled))
                        {
                            mSwitchOutfitHelper.Dispose();
                            return(false);
                        }
                        SpeedTrap.Sleep(0xa);
                    }
                }

                msg += "A";

                if (!Actor.RouteToSlot(Shower, Slot.RoutingSlot_0))
                {
                    mSwitchOutfitHelper.Dispose();
                    return(false);
                }

                msg += "B";

                mSwitchOutfitHelper.Wait(true);
                bool flag = Actor.GetCurrentOutfitCategoryFromOutfitInGameObject() == OutfitCategories.Singed;
                Shower.AddToUseList(Actor);
                mInUseList           = true;
                mCurrentStateMachine = TakeShowerInst.mCurrentStateMachine;
                SetActorAndEnter("y", Actor, "Enter");
                if (!WaitForBToEnterShower)
                {
                    mCurrentStateMachine.RequestState("y", "Ask");
                }

                msg += "C";

                string socialName = CommonWoohoo.GetSocialName(definition.GetStyle(this), Actor);
                StartSocial(socialName);

                if (WaitForBToEnterShower)
                {
                    Rejected = false;
                }

                InitiateSocialUI(Actor, Target);

                msg += "D";

                bool succeeded = true;
                if (Rejected)
                {
                    succeeded = false;
                    mCurrentStateMachine.RequestState("y", "Reject");
                    mCurrentStateMachine.RemoveActor(Actor);
                    FinishSocial(socialName, true);
                    Actor.BuffManager.AddElement(BuffNames.WalkOfShame, Origin.FromRejectedWooHooOffHome);
                }
                else
                {
                    mCurrentStateMachine.RequestState("y", "ShooSims");
                    SetParameter("SimShouldClothesChange", !flag && !Actor.OccultManager.DisallowClothesChange());
                    mSwitchOutfitHelper.AddScriptEventHandler(this);
                    Actor.LoopIdle();

                    msg += "E";

                    if (CommonWoohoo.NeedPrivacy(Shower.IsOutside, Actor, Target))
                    {
                        mSituation = new BedWoohoo.WooHooPrivacySituation(this);
                        if (!mSituation.Start())
                        {
                            mSwitchOutfitHelper.Dispose();
                            succeeded = false;
                        }
                    }

                    msg += "F";

                    if ((succeeded) && (Actor.RouteToSlot(Shower, Slot.RoutingSlot_0)))
                    {
                        MotiveDelta[] deltaArray = new MotiveDelta[6];
                        deltaArray[0] = AddMotiveDelta(CommodityKind.Fun, 1500f);
                        deltaArray[1] = TakeShowerInst.AddMotiveDelta(CommodityKind.Fun, 1500f);
                        deltaArray[2] = AddMotiveDelta(CommodityKind.Social, 50f);
                        deltaArray[3] = TakeShowerInst.AddMotiveDelta(CommodityKind.Social, 50f);
                        if (Actor.SimDescription.IsPlantSim)
                        {
                            deltaArray[4] = AddMotiveDelta(CommodityKind.Hygiene, 800f * Sims3.Gameplay.Objects.Plumbing.Shower.kPlantSimHygieneModifier);
                        }
                        else
                        {
                            deltaArray[4] = AddMotiveDelta(CommodityKind.Hygiene, 800f);
                        }

                        if (Actor.SimDescription.IsMermaid)
                        {
                            deltaArray[5] = AddMotiveDelta(CommodityKind.MermaidDermalHydration, 800f);
                        }

                        Target.EnableCensor(Sim.CensorType.FullHeight);
                        RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);
                        mCurrentStateMachine.AddOneShotScriptEventHandler(0x65, OnJealousyEvent);
                        mCurrentStateMachine.AddOneShotScriptEventHandler(0x66, OnAnimationEvent);

                        if (CommonPregnancy.IsSuccess(Actor, Target, Autonomous, definition.GetStyle(this)))
                        {
                            mCurrentStateMachine.AddOneShotScriptEventHandler(0x67, OnPregnancyEvent);
                        }

                        msg += "G";

                        mSteamVfx = VisualEffect.Create(Shower.SteamVfxName);
                        mSteamVfx.ParentTo(Shower, Shower.IsShowerTub ? Slot.FXJoint_2 : Slot.FXJoint_0);
                        mSteamVfx.Start();
                        mCurrentStateMachine.RequestState(null, "BreatheIdle");
                        RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo);

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

                        msg += "H";

                        Sims3.Gameplay.Objects.Plumbing.Shower.WaitToLeaveShower(Actor, Shower);

                        // Custom
                        ShowerEx.ApplyPostShowerEffects(Actor, Shower);
                        if (flag)
                        {
                            mSwitchOutfitHelper.Dispose();
                            mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, Sim.ClothesChangeReason.GoingToBathe);
                            mSwitchOutfitHelper.Start();
                            mSwitchOutfitHelper.Wait(false);
                            mSwitchOutfitHelper.ChangeOutfit();
                        }

                        msg += "I";

                        mSwitchOutfitHelper.Dispose();
                        mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, Sim.ClothesChangeReason.GettingOutOfBath);
                        mSwitchOutfitHelper.Start();
                        mSwitchOutfitHelper.AddScriptEventHandler(this);
                        mSwitchOutfitHelper.Wait(false);
                        RemoveMotiveDelta(deltaArray[0x0]);
                        TakeShowerInst.RemoveMotiveDelta(deltaArray[0x1]);
                        RemoveMotiveDelta(deltaArray[0x2]);
                        TakeShowerInst.RemoveMotiveDelta(deltaArray[0x3]);
                        RemoveMotiveDelta(deltaArray[0x4]);

                        if (Actor.SimDescription.IsMermaid)
                        {
                            RemoveMotiveDelta(deltaArray[0x5]);
                        }

                        mCurrentStateMachine.RequestState("y", "Exit Working Y");
                        Target.AutoEnableCensor();

                        msg += "J";
                    }

                    mCurrentStateMachine.RemoveActor(Actor);
                    FinishSocial(socialName, true);
                }

                msg += "K";

                Shower.RemoveFromUseList(Actor);
                mInUseList = false;
                Actor.RouteAway(Sims3.Gameplay.Objects.Plumbing.Shower.kMinDistanceToMoveAwayFromShower, Sims3.Gameplay.Objects.Plumbing.Shower.kMaxDistanceToMoveAwayFromShower, false, GetPriority(), true, true, true, RouteDistancePreference.PreferFurthestFromRouteOrigin);
                if (mSteamVfx != null)
                {
                    mSteamVfx.Stop();
                    mSteamVfx = null;
                }

                msg += "L";

                EndCommodityUpdates(succeeded);
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
            finally
            {
                if (TakeShowerInst != null)
                {
                    TakeShowerInst.HavingWooHoo = false;
                }
            }
        }
Exemplo n.º 2
0
        public override bool Run()
        {
            try
            {
                if (!Target.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.DefaultEvict, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), Shower.kTimeToWaitToEvict))
                {
                    return(false);
                }

                try
                {
                    mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, OutfitChoice);
                }
                catch
                {
                    return(false);
                }

                mSwitchOutfitHelper.Start();
                if (Actor.HasTrait(TraitNames.Hydrophobic))
                {
                    Actor.PlayReaction(ReactionTypes.WhyMe, Target as GameObject, ReactionSpeed.ImmediateWithoutOverlay);
                }
                if (Actor.HasTrait(TraitNames.Daredevil))
                {
                    TraitTipsManager.ShowTraitTip(0xb82d0015b9294260L, Actor, TraitTipsManager.TraitTipCounterIndex.Daredevil, TraitTipsManager.kDaredevilCountOfShowersTaken);
                }

                if (!Actor.RouteToSlotAndCheckInUse(Target, Slot.RoutingSlot_0))
                {
                    return(false);
                }

                if (EnforcePrivacy)
                {
                    mSituation = new Shower.ShowerPrivacySituation(this);
                    if (!mSituation.Start())
                    {
                        return(false);
                    }
                }

                StandardEntry();
                if (!Actor.RouteToSlot(Target, Slot.RoutingSlot_0))
                {
                    if (mSituation != null)
                    {
                        mSituation.Exit();
                    }

                    StandardExit();
                    return(false);
                }
                if (Autonomous)
                {
                    mPriority = new InteractionPriority(InteractionPriorityLevel.UserDirected);
                }
                mSwitchOutfitHelper.Wait(true);
                bool daredevilPerforming = Actor.DaredevilPerforming;
                bool flag2 = Actor.GetCurrentOutfitCategoryFromOutfitInGameObject() == OutfitCategories.Singed;
                EnterStateMachine("Shower", "Enter", "x");
                SetActor("Shower", Target);
                if (mSituation != null)
                {
                    mSituation.StateMachine = mCurrentStateMachine;
                }
                SetParameter("IsShowerTub", Target.IsShowerTub);
                SetParameter("SimShouldCloseDoor", true); // Required to be "true" for the Oufit switcher
                SetParameter("SimShouldClothesChange", ((!daredevilPerforming && !flag2) && !Actor.OccultManager.DisallowClothesChange()) && !Actor.BuffManager.DisallowClothesChange());

                bool paramValue = false;
                if ((Target.BoobyTrapComponent != null) && Target.BoobyTrapComponent.CanTriggerTrap(Actor.SimDescription))
                {
                    paramValue = !Actor.OccultManager.DisallowClothesChange() && !Actor.BuffManager.DisallowClothesChange();
                }
                SimDescription description = ((Target.BoobyTrapComponent != null) && (Target.BoobyTrapComponent.TrapSetter != 0L)) ? SimDescription.Find(Target.BoobyTrapComponent.TrapSetter) : null;
                if (((description != null) && description.IsFairy) && Actor.BuffManager.HasElement(BuffNames.TrickedByAFairy))
                {
                    paramValue = false;
                }
                SetParameter("isBoobyTrapped", paramValue);
                mSwitchOutfitHelper.AddScriptEventHandler(this);
                AddOneShotScriptEventHandler(0x3e9, EventCallbackStartShoweringSound);
                if (Actor.HasTrait(TraitNames.Virtuoso) || RandomUtil.RandomChance((float)Target.TuningShower.ChanceOfSinging))
                {
                    AddOneShotScriptEventHandler(0xc8, EventCallbackStartSinging);
                }
                PetStartleBehavior.CheckForStartle(Target as GameObject, StartleType.ShowerOn);
                AnimateSim("Loop Shower");
                Actor.BuffManager.AddElement(BuffNames.SavingWater, Origin.FromShower, ProductVersion.EP2, TraitNames.EnvironmentallyConscious);
                mShowerStage.ResetCompletionTime(GetShowerTime());
                StartStages();
                if (Actor.HasTrait(TraitNames.EnvironmentallyConscious))
                {
                    BeginCommodityUpdate(CommodityKind.Hygiene, Shower.kEnvironmentallyConsciousShowerSpeedMultiplier);
                }
                if (Actor.SimDescription.IsPlantSim)
                {
                    ModifyCommodityUpdate(CommodityKind.Hygiene, Shower.kPlantSimHygieneModifier);
                }

                BeginCommodityUpdates();

                if (paramValue)
                {
                    ApplyBoobyTrapOutfit();
                    if ((description != null) && description.IsFairy)
                    {
                        Actor.BuffManager.AddElement(BuffNames.TrickedByAFairy, Origin.FromFairy);
                    }
                }

                bool succeeded = false;
                try
                {
                    try
                    {
                        Target.SimInShower = Actor;
                        succeeded          = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), DuringShower, null);
                        if (HavingWooHoo && Actor.HasExitReason(ExitReason.StageComplete))
                        {
                            succeeded = DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached | ExitReason.StageComplete), DuringShower, null);
                        }
                    }
                    finally
                    {
                        Target.SimInShower = null;
                    }

                    while (HavingWooHoo)
                    {
                        SpeedTrap.Sleep(10);
                    }
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                }

                Shower.WaitToLeaveShower(Actor, Target);
                if (succeeded)
                {
                    ShowerEx.ApplyPostShowerEffects(Actor, Target);
                }
                if (paramValue)
                {
                    SetParameter("isBoobyTrapped", false);
                    AddOneShotScriptEventHandler(0xc9, EventCallbackStopSinging);
                    AddOneShotScriptEventHandler(0x3ea, EventCallbackStopShoweringSound);
                    if ((description != null) && description.IsFairy)
                    {
                        AnimateSim("TriggerFairyTrap");
                    }
                    else
                    {
                        AnimateSim("Booby Trap Reaction");
                    }
                    AddOneShotScriptEventHandler(0x3e9, EventCallbackStartShoweringSound);
                    AnimateSim("Loop Shower");
                    RemoveBoobyTrapOutfit();
                    SpeedTrap.Sleep(60);
                }

                try
                {
                    if (flag2 && succeeded)
                    {
                        mSwitchOutfitHelper.Dispose();
                        try
                        {
                            mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, OutfitChoice);
                            mSwitchOutfitHelper.Start();
                            mSwitchOutfitHelper.Wait(false);
                            mSwitchOutfitHelper.ChangeOutfit();
                        }
                        catch
                        { }
                    }
                    bool flag5 = false;
                    if ((flag2 && succeeded) || (!flag2 && !daredevilPerforming))
                    {
                        SetParameter("SimShouldClothesChange", !Actor.OccultManager.DisallowClothesChange());
                        mSwitchOutfitHelper.Dispose();
                        try
                        {
                            mSwitchOutfitHelper = new Sim.SwitchOutfitHelper(Actor, GetOutfitReason(Actor));
                            mSwitchOutfitHelper.Start();
                            mSwitchOutfitHelper.AddScriptEventHandler(this);
                            mSwitchOutfitHelper.Wait(false);
                        }
                        catch
                        { }

                        flag5 = true;
                    }

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

                    AddOneShotScriptEventHandler(0xc9, EventCallbackStopSinging);
                    AddOneShotScriptEventHandler(0x3ea, EventCallbackStopShoweringSound);
                    if (flag5 && InventingSkill.IsBeingDetonated(Target as GameObject))
                    {
                        SetParameter("SimShouldClothesChange", false);
                        mSwitchOutfitHelper.Abort();
                        mSwitchOutfitHelper.Dispose();
                    }

                    if ((Target.Repairable != null) && (Target.Repairable.UpdateBreakage(Actor)))
                    {
                        Target.StartBrokenFXInAnim(mCurrentStateMachine);
                        AnimateSim("Exit Broken");
                    }
                    else
                    {
                        AnimateSim("Exit Working");
                    }

                    if ((Actor.SimDescription.IsMummy || Actor.DaredevilPerforming) || (Actor.TraitManager.HasElement(TraitNames.Slob) && RandomUtil.RandomChance01(TraitTuning.SlobTraitChanceToLeavePuddle)))
                    {
                        PuddleManager.AddPuddle(Actor.Position);
                    }

                    if (succeeded)
                    {
                        Actor.BuffManager.RemoveElement(BuffNames.GotFleasHuman);
                    }
                }
                finally
                {
                    StandardExit();
                }
                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }