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

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

            newMachine.SetActor("x", parent);
            newMachine.SetActor("y", child);
            newMachine.EnterState("x", "Enter");
            newMachine.EnterState("y", "Enter");
            return(newMachine);
        }
Ejemplo n.º 3
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.º 4
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);
        }
Ejemplo n.º 5
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.º 6
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.º 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);
        }
        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.º 9
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.º 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
        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.º 12
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.º 13
0
        public static bool SitDown(HotTubBase ths, Sim s, Slot slot, HotTubSeat seat, Sim.SwitchOutfitHelper switchOutfitHelper, bool isSkinnyDipping, Sim invitedBy, bool isAutonomous)
        {
            bool flag       = isSkinnyDipping;
            bool paramValue = true;

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

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

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

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

            if (!paramValue)
            {
                flag = false;
            }

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

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

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

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

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

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

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

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

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

            EventTracker.SendEvent(new Event(EventTypeId.kGoHotTubbing, s, ths));
            if (isSkinnyDipping)
            {
                StartSkinnyDipBroadcastersAndSendWishEvents(ths, s);
            }
            return(true);
        }
Ejemplo n.º 14
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.º 15
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.º 16
0
        public override bool Run()
        {
            try
            {
                if (WoohooHouse == null)
                {
                    return(false);
                }
                if (!SafeToSync())
                {
                    return(false);
                }
                PetHouse.WoohooPetHouseB entry = PetHouse.WoohooPetHouseB.Singleton.CreateInstance(Actor, Target, GetPriority(), Autonomous, CancellableByPlayer) as PetHouse.WoohooPetHouseB;
                entry.LinkedInteractionInstance = this;
                Target.InteractionQueue.Add(entry);
                Actor.SynchronizationLevel  = Sim.SyncLevel.Started;
                Actor.SynchronizationTarget = Target;
                Actor.SynchronizationRole   = Sim.SyncRole.Initiator;
                if (!WoohooHouse.SimLine.WaitForTurn(this, SimQueue.WaitBehavior.Default, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), 10f))
                {
                    return(false);
                }
                if (!Actor.RouteToSlotAndCheckInUse(WoohooHouse, Slot.RoutingSlot_3))
                {
                    if (!Actor.HasExitReason(ExitReason.RouteFailed))
                    {
                        WoohooHouse.SimLine.RemoveFromQueue(Actor);
                        WoohooHouse.PlayRouteFailAndWanderAway(Actor);
                        return(false);
                    }
                    Actor.RemoveExitReason(ExitReason.RouteFailed);
                    if (!Actor.RouteToSlotAndCheckInUse(WoohooHouse, Slot.RoutingSlot_3))
                    {
                        WoohooHouse.SimLine.RemoveFromQueue(Actor);
                        WoohooHouse.PlayRouteFailAndWanderAway(Actor);
                        return(false);
                    }
                }
                StandardEntry();
                WoohooHouse.AddToUseList(Actor);
                WoohooHouse.AddToUseList(Target);
                EnterStateMachine("PetHouse", "enter", "x");
                SetActor("petHouse", WoohooHouse);
                SetActor("y", Target);
                Animate("x", "getInWoohooX");
                Actor.ParentToSlot(WoohooHouse, WoohooHouse.GetContainmentSlotForActor(Actor));
                WoohooHouse.SimLine.RemoveFromQueue(Actor);
                if (!Actor.WaitForSynchronizationLevelWithSim(Target, Sim.SyncLevel.Routed, 30f))
                {
                    Actor.UnParent();
                    Animate("x", "inHouseNeutral");
                    Animate("x", "exit");
                    StandardExit();
                    WoohooHouse.RemoveFromUseList(Actor);
                    WoohooHouse.RemoveFromUseList(Target);
                    return(false);
                }
                BeginCommodityUpdates();
                (LinkedInteractionInstance as PetHouse.WoohooPetHouseB).BeginCommodityUpdates();
                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.MoreWoohoo);
                EnterState("y", "enter");
                Animate("y", "getInWoohooY");
                AnimateJoinSims("woohoo");
                Actor.UnParent();
                AnimateSim("exitWoohoo");
                RockGemMetalBase.HandleNearbyWoohoo(Actor, RockGemMetalBase.HowMuchWooHoo.LessWoohoo);

                IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;

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

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

                StateMachineClient smc = StateMachineClient.Acquire(Actor, "PetHouse");
                smc.SetActor("petHouse", WoohooHouse);
                smc.SetActor("x", Actor);
                smc.EnterState("x", "inHouseNeutral");
                PetHouse.PetHousePosture posture = new PetHouse.PetHousePosture(WoohooHouse, Actor, smc);
                Actor.Posture       = posture;
                ActorStayingInHouse = Actor.InteractionQueue.PushAsContinuation(PetHouse.LieDown.Singleton.CreateInstance(WoohooHouse, Actor, GetPriority(), Autonomous, CancellableByPlayer), true);
                if (!ActorStayingInHouse)
                {
                    posture.CancelPosture(Actor);
                }
                EndCommodityUpdates(true);
                (LinkedInteractionInstance as PetHouse.WoohooPetHouseB).EndCommodityUpdates(true);
                PlumbBob.Reparent();
                StandardExit();
                return(true);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception exception)
            {
                Common.Exception(Actor, Target, exception);
                return(false);
            }
        }
Ejemplo n.º 17
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.º 18
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.º 19
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.º 20
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);
            }
        }