示例#1
0
        public static void PerformeInteraction(Sim sim, SculptureFloorClothingRack2x1 target, InteractionDefinition definition)
        {
            InteractionPriority priority = new InteractionPriority(InteractionPriorityLevel.UserDirected);
            InteractionInstance entry    = definition.CreateInstance(target, sim, priority, false, true);

            sim.InteractionQueue.Add(entry);
        }
示例#2
0
        private void pushSimToPeeBeforeShow(Sim sim)
        {
            try
            {
                IToilet toilet = findNearestToilet(sim);
                if (toilet != null && !toilet.InUse)
                {
                    List <InteractionObjectPair> interactions  = toilet.GetAllInteractionsForActor(sim);
                    InteractionDefinition        peeDefinition = null;
                    foreach (InteractionObjectPair interaction in interactions)
                    {
                        InteractionDefinition interactionDef = interaction.InteractionDefinition;
                        string name = interactionDef.GetType().ToString();


                        if (name != null && name.Contains("UseToilet"))
                        {
                            peeDefinition = interactionDef;
                            break;
                        }
                    }

                    if (peeDefinition != null)
                    {
                        InteractionInstance instance = peeDefinition.CreateInstance(toilet, sim,
                                                                                    new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), false, false);
                        sim.InteractionQueue.AddAfterCheckingForDuplicates(instance);
                    }
                }
            }
            catch (Exception ex)
            {
                Message.Sender.ShowError(this, "Sim cannot pee before show", false, ex);
            }
        }
示例#3
0
        public override InteractionInstance CreateVisitInteractionForSim(Sim sim, InteractionDefinition defToPush, List <Sim> alreadyAdded, ref Dictionary <Sim, bool> simArrivalStatus)
        {
            VisitRabbitHoleEx hole = defToPush.CreateInstance(Target, sim, mPriority, false, true) as VisitRabbitHoleEx;

            if (hole != null)
            {
                hole.TourGroup.AddRange(alreadyAdded);
            }
            return(hole);
        }
示例#4
0
        public override bool Run()
        {
            try
            {
                Sim selectedObject = GetSelectedObject() as Sim;
                if (selectedObject != null)
                {
                    Run();
                    if (mResultCode != SocialInteraction.SocialResultCode.Succeeded)
                    {
                        return(false);
                    }

                    SocialRule targetEffect = mTargetEffect;
                    if (targetEffect != null)
                    {
                        if (targetEffect.RHS.STEffectCommodity != CommodityTypes.Friendly)
                        {
                            return(false);
                        }

                        Definition            interactionDefinition = InteractionDefinition as Definition;
                        InteractionPriority   priority    = GetPriority();
                        InteractionDefinition definition2 = interactionDefinition.GetPushDefintion(Target, selectedObject, priority);
                        if (definition2 == null)
                        {
                            return(false);
                        }
                        InteractionInstance instance = definition2.CreateInstance(selectedObject, Target, priority, false, true);
                        if (!Target.InteractionQueue.PushAsContinuation(instance, true))
                        {
                            return(false);
                        }

                        Assassination skill = Assassination.EnsureSkill(Target);

                        skill.AddJob(Actor, selectedObject);

                        return(true);
                    }
                }
                return(false);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
示例#5
0
        //Performe the random interaction


        private static void PerformeInteractionOnSelf(Sim sim, InteractionDefinition definition)
        {
            InteractionPriority priority = sim.CurrentInteraction.GetPriority();

            InteractionInstance instance3 = definition.CreateInstance(sim, sim, priority, false, true);

            sim.InteractionQueue.Add(instance3);

            if (AddMenuItem.ReturnShowNotification())
            {
                StyledNotification.Show(new StyledNotification.Format(sim.Name + "\r" + instance3.GetInteractionName(), StyledNotification.NotificationStyle.kGameMessagePositive));
            }
        }
示例#6
0
        public static void AddWooHooToQue(BedDouble bed, Sim actor, Sim recipient, InteractionDefinition definition)
        {
            actor.GreetSimOnMyLotIfPossible(recipient);
            InteractionPriority priority = actor.CurrentInteraction.GetPriority();
            InteractionInstance entry    = OverridedEnterRelaxing.Singleton.CreateInstance(bed, actor, priority, false, true);

            if (actor.InteractionQueue.Add(entry))
            {
                InteractionInstance instance2 = OverridedEnterRelaxing.Singleton.CreateInstance(bed, recipient, priority, false, true);
                recipient.InteractionQueue.Add(instance2);
                InteractionInstance instance3 = definition.CreateInstance(recipient, actor, priority, actor.CurrentInteraction.Autonomous, true);
                instance3.GroupId = entry.GroupId;
                actor.InteractionQueue.Add(instance3);
            }
        }
示例#7
0
        private void PushSimToDrink(Actors.Sim sim, IBarProfessional bar, String bestDrinkName)
        {
            List <InteractionObjectPair> interactions       = bar.GetAllInteractionsForActor(sim);
            InteractionDefinition        drinkingDefinition = null;

            foreach (InteractionObjectPair interaction in interactions)
            {
                InteractionDefinition interactionDef = interaction.InteractionDefinition;
                string name = interactionDef.GetInteractionName(sim, bar, interaction);

                if (name != null && name.Contains(bestDrinkName))
                {
                    drinkingDefinition = interactionDef;
                    break;
                }
            }

            if (drinkingDefinition != null)
            {
                IEnumerable <InteractionInstance> actions  = sim.InteractionQueue.InteractionList;
                List <InteractionInstance>        toCancel = new List <InteractionInstance>();
                bool alreadyDrinking = false;
                foreach (InteractionInstance action in actions)
                {
                    if (!(action is BarProfessional.BarInteraction))
                    {
                        toCancel.Add(action);
                    }
                    else
                    {
                        alreadyDrinking = true;
                        break;
                    }
                }

                foreach (InteractionInstance action in toCancel)
                {
                    sim.InteractionQueue.CancelInteraction(action, false);
                }
                if (!alreadyDrinking)
                {
                    sim.InteractionQueue.AddAfterCheckingForDuplicates(drinkingDefinition.CreateInstance(bar, sim, new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), true, false));
                }
            }
        }
示例#8
0
        protected override bool Push()
        {
            if (Sim.CreatedSim == null)
            {
                return(false);
            }

            if (!Situations.Allow(this, Sim))
            {
                return(false);
            }

            if (Sim.CreatedSim.InteractionQueue != null)
            {
                Sim.CreatedSim.InteractionQueue.CancelAllInteractions();
            }

            PoliceStation target = ManagerSituation.FindRabbitHole(RabbitHoleType.PoliceStation) as PoliceStation;

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

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

            InteractionDefinition pushInteraction = OnPushInteraction();

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

            InteractionInstance entry = pushInteraction.CreateInstance(target, Sim.CreatedSim, new InteractionPriority(InteractionPriorityLevel.High), false, false);

            Sim.CreatedSim.AddExitReason(ExitReason.CanceledByScript);
            Sim.CreatedSim.InteractionQueue.AddNext(entry);

            return(true);
        }
示例#9
0
        public override InteractionInstance CreateVisitInteractionForSim(Sim sim, InteractionDefinition defToPush, List <Sim> alreadyAdded, ref Dictionary <Sim, bool> simArrivalStatus)
        {
            TakeElevatorToTopEx hole = defToPush.CreateInstance(Target, sim, mPriority, false, true) as TakeElevatorToTopEx;

            if (hole != null)
            {
                hole.TourGroup.AddRange(alreadyAdded);
                if (base.InteractionDefinition is ElevatorDefinition)
                {
                    if (simArrivalStatus == null)
                    {
                        simArrivalStatus = new Dictionary <Sim, bool> ();
                    }
                    simArrivalStatus.Add(sim, false);
                    hole.SimArrivalStatus = simArrivalStatus;
                }
            }
            return(hole);
        }
示例#10
0
            protected override void OnPerform()
            {
                WoohooLocationControl location = null;

                if (mObject == null)
                {
                    mObject = GetRandomObject(mActor.SimDescription, out location);
                }

                if ((mObject == null) || (location == null))
                {
                    return;
                }

                InteractionDefinition interaction = location.GetInteraction(mActor, mTarget, mStyle);

                if (interaction != null)
                {
                    IWooHooDefinition woohooDefinition = interaction as IWooHooDefinition;
                    if (woohooDefinition != null)
                    {
                        woohooDefinition.Attempts = mAttempts;
                    }

                    InteractionInstance instance = interaction.CreateInstance(mObject, mActor, new InteractionPriority(InteractionPriorityLevel.UserDirected), false, true);

                    if ((mActor.InteractionQueue != null) && (mActor.InteractionQueue.Add(instance)))
                    {
                        ScoringLookup.IncStat("Push Success " + location + " " + mStyle);
                    }
                    else
                    {
                        ScoringLookup.IncStat("Push Fail " + location + " " + mStyle);
                    }
                }
            }
示例#11
0
 public static void PerformeInteraction(Sim sim, GameObject target, InteractionDefinition definition)
 {
     InteractionPriority priority = new InteractionPriority(InteractionPriorityLevel.UserDirected);
     InteractionInstance entry = definition.CreateInstance(target, sim, priority, false, true);
     sim.InteractionQueue.Add(entry);
 }
示例#12
0
        public override void Perform(Sim sim, DiseaseVector vector)
        {
            if (SimTypes.IsDead(sim.SimDescription))
            {
                return;
            }

            if (!mAllowActive)
            {
                if (SimTypes.IsSelectable(sim.SimDescription))
                {
                    return;
                }
            }

            bool found = false;

            foreach (Sim other in sim.LotCurrent.GetSims())
            {
                if (other == sim)
                {
                    continue;
                }

                if (ScoringLookup.GetScore(mScoring, other.SimDescription) >= mMinimum)
                {
                    found = true;
                    break;
                }
            }

            if (found)
            {
                return;
            }

            List <Lot> lots = new List <Lot>(LotManager.sLots.Values);

            while (lots.Count > 0)
            {
                Lot lot = RandomUtil.GetRandomObjectFromList(lots);
                lots.Remove(lot);

                if (lot.IsWorldLot)
                {
                    continue;
                }

                if (lot == sim.LotCurrent)
                {
                    continue;
                }

                foreach (Sim other in lot.GetSims())
                {
                    if (ScoringLookup.GetScore(mScoring, other.SimDescription) >= mMinimum)
                    {
                        InteractionDefinition definition = null;

                        if (lot.IsCommunityLot)
                        {
                            definition = VisitCommunityLot.Singleton;
                        }
                        else
                        {
                            if (sim.IsGreetedOnLot(lot))
                            {
                                definition = GoToLot.Singleton;
                            }
                            else
                            {
                                definition = VisitLot.Singleton;
                            }
                        }

                        InteractionInstance instance = definition.CreateInstance(lot, sim, new InteractionPriority(InteractionPriorityLevel.Autonomous), true, true);
                        sim.InteractionQueue.Add(instance);

                        return;
                    }
                }
            }
        }
示例#13
0
        private void PushSimToDrink(Actors.Sim sim, IBarProfessional bar, String bestDrinkName)
        {
            if (Message.Sender.IsDebugging())
            {
                Message.Sender.Debug(this, "Best drink for " + sim.FullName + " is: " + bestDrinkName);
            }
            List <InteractionObjectPair> interactions       = bar.GetAllInteractionsForActor(sim);
            InteractionDefinition        drinkingDefinition = null;

            foreach (InteractionObjectPair interaction in interactions)
            {
                InteractionDefinition interactionDef = interaction.InteractionDefinition;
                string name = interactionDef.GetInteractionName(sim, bar, interaction);

                if (name != null && name.Contains(bestDrinkName))
                {
                    drinkingDefinition = interactionDef;
                    break;
                }
            }

            if (drinkingDefinition != null)
            {
                IEnumerable <InteractionInstance> actions  = sim.InteractionQueue.InteractionList;
                List <InteractionInstance>        toCancel = new List <InteractionInstance>();
                bool alreadyDrinking = false;
                foreach (InteractionInstance action in actions)
                {
                    if (!(action is BarProfessional.BarInteraction))
                    {
                        if (Message.Sender.IsDebugging())
                        {
                            Message.Sender.Debug(this, "Canceling " + action.GetInteractionName());
                        }
                        toCancel.Add(action);
                    }
                    else
                    {
                        if (Message.Sender.IsDebugging())
                        {
                            Message.Sender.Debug(this, "Sim is already drinking, no push added");
                        }
                        alreadyDrinking = true;
                        break;
                    }
                }

                foreach (InteractionInstance action in toCancel)
                {
                    sim.InteractionQueue.CancelInteraction(action, false);
                }
                if (!alreadyDrinking)
                {
                    sim.InteractionQueue.AddAfterCheckingForDuplicates(drinkingDefinition.CreateInstance(bar, sim, new InteractionPriority(InteractionPriorityLevel.RequiredNPCBehavior), true, false));
                    if (Message.Sender.IsDebugging())
                    {
                        Message.Sender.Debug(this, "Sim was pushed to drink: " + sim.FullName);
                    }
                }
            }
        }
示例#14
0
        public override bool Run()
        {
            try
            {
                Actor.GreetSimOnMyLotIfPossible(Target);

                if (StartBedCuddleA.GetCuddleType(Actor, Target) == StartBedCuddleA.CuddleType.CuddleTargetOnDifferentBed)
                {
                    ChildUtils.SetPosturePrecondition(this, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget });
                    Actor.InteractionQueue.PushAsContinuation(this, true);

                    return(true);
                }

                BedMultiPart container = null;

                try
                {
                    if (Actor.Posture == null)
                    {
                        return(false);
                    }

                    if (!Actor.Posture.Satisfies(CommodityKind.Relaxing, null))
                    {
                        return(false);
                    }

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

                    container = Actor.Posture.Container as BedMultiPart;

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

                    if (IsMaster && ReturnInstance == null)
                    {
                        EnterStateMachine("BedSocials", "FromRelax", "x", "y");
                        AddPersistentScriptEventHandler(0x0, EventCallbackChangeVisibility);
                        SetActor("bed", container);
                        container.PartComp.GetPartSimIsIn(Actor).SetPartParameters(mCurrentStateMachine);
                        WooHoo interaction = InteractionDefinition.CreateInstance(Actor, Target, GetPriority(), false, CancellableByPlayer) as WooHoo;
                        interaction.IsMaster = false;
                        interaction.LinkedInteractionInstance = this;
                        ChildUtils.SetPosturePrecondition(interaction, CommodityKind.Relaxing, new CommodityKind[] { CommodityKind.NextToTarget });
                        Target.InteractionQueue.AddNext(interaction);

                        if (Target.Posture.Container != Actor.Posture.Container)
                        {
                            Actor.LookAtManager.SetInteractionLookAt(Target, 0xc8, LookAtJointFilter.TorsoBones);
                            Actor.Posture.CurrentStateMachine.RequestState("x", "callOver");
                        }

                        Actor.SynchronizationLevel  = Sim.SyncLevel.Started;
                        Actor.SynchronizationTarget = Target;
                        Actor.SynchronizationRole   = Sim.SyncRole.Initiator;

                        if (!StartSync(IsMaster))
                        {
                            return(false);
                        }

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

                        Actor.SocialComponent.StartSocializingWith(Target);
                    }
                    else if (!StartSync(IsMaster))
                    {
                        return(false);
                    }
                }
                catch (ResetException)
                {
                    throw;
                }
                catch (Exception e)
                {
                    Common.DebugException(Actor, Target, e);
                    return(false);
                }

                StandardEntry(false);
                BeginCommodityUpdates();
                bool succeeded = false;

                try
                {
                    if (IsMaster)
                    {
                        if (CommonWoohoo.NeedPrivacy(container.InherentlyProvidesPrivacy, Actor, Target))
                        {
                            mSituation = new WooHooPrivacySituation(this);

                            if (!mSituation.Start())
                            {
                                FinishLinkedInteraction();
                                PostLoop();

                                if (ReturnInstance == null)
                                {
                                    InteractionInstance instance = BedRelax.Singleton.CreateInstance(Actor.Posture.Container, Actor, GetPriority(), true, true);
                                    Actor.InteractionQueue.PushAsContinuation(instance, true);
                                }
                                else
                                {
                                    DoResume();
                                }

                                WooHoo linkedInteractionInstance = LinkedInteractionInstance as WooHoo;

                                if (linkedInteractionInstance != null)
                                {
                                    if (ReturnInstance == null)
                                    {
                                        InteractionInstance instance2 = BedRelax.Singleton.CreateInstance(Target.Posture.Container, Target, GetPriority(), true, true);
                                        Target.InteractionQueue.PushAsContinuation(instance2, true);
                                    }
                                    else
                                    {
                                        linkedInteractionInstance.DoResume();
                                    }

                                    linkedInteractionInstance.Failed = true;
                                }

                                WaitForSyncComplete();

                                return(false);
                            }
                        }

                        IWooHooDefinition definition = InteractionDefinition as IWooHooDefinition;
                        Actor.LookAtManager.ClearInteractionLookAt();
                        Target.LookAtManager.ClearInteractionLookAt();

                        if (ReturnInstance != null)
                        {
                            ReturnInstance.EnsureMaster();
                            mCurrentStateMachine = ReturnInstance.mCurrentStateMachine;
                        }

                        StartSocial(CommonSurrogate.GetSocialName(definition.GetStyle(this)));
                        InitiateSocialUI(Actor, Target);
                        WooHoo linked = LinkedInteractionInstance as WooHoo;

                        if (linked != null)
                        {
                            linked.Rejected = Rejected;
                        }

                        if (Rejected)
                        {
                            if (Actor.Posture.Container == Target.Posture.Container)
                            {
                                ThoughtBalloonManager.BalloonData bd = new ThoughtBalloonManager.DoubleBalloonData("balloon_woohoo", "balloon_question");
                                bd.BalloonType = ThoughtBalloonTypes.kSpeechBalloon;
                                Actor.ThoughtBalloonManager.ShowBalloon(bd);
                                AddOneShotScriptEventHandler(0x194, ShowRejectBalloonAndEnqueueRouteAway);
                                mCurrentStateMachine.RequestState(false, "x", "WooHooReject");
                                mCurrentStateMachine.RequestState(true, "y", "WooHooReject");
                                mCurrentStateMachine.RequestState(true, null, "ToRelax");
                            }
                        }
                        else
                        {
                            mCurrentStateMachine.AddOneShotScriptEventHandler(0x6e, OnPregnancyEvent);
                            mCurrentStateMachine.AddOneShotScriptEventHandler(0x6e, EventCallbackChangeClothes);
                            string wooHooEffectName = container.TuningBed.WooHooEffectName;

                            if (!string.IsNullOrEmpty(wooHooEffectName))
                            {
                                mWooHooEffect = VisualEffect.Create(wooHooEffectName);
                                mWooHooEffect.ParentTo(container, Slots.Hash("_FX_0"));
                                AddOneShotScriptEventHandler(0xc8, EventCallbackWooHoo);
                                AddOneShotScriptEventHandler(0xc9, EventCallbackWooHoo);
                            }

                            if (container is BedDreamPod)
                            {
                                AddOneShotScriptEventHandler(0xc8, EventCallbackDreamPodWooHoo);
                                AddOneShotScriptEventHandler(0xc9, EventCallbackDreamPodWooHoo);
                            }

                            Sim.ClothesChangeReason reason = Sim.ClothesChangeReason.GoingToBed;

                            if ((Woohooer.Settings.mNakedOutfitBed) && (!container.IsOutside))
                            {
                                reason = Sim.ClothesChangeReason.GoingToBathe;
                                Woohooer.Settings.AddChange(Actor);
                                Woohooer.Settings.AddChange(Target);
                            }

                            mHelperX = new Sim.SwitchOutfitHelper(Actor, reason);
                            mHelperY = new Sim.SwitchOutfitHelper(Target, reason);
                            mHelperX.Start();
                            mHelperY.Start();
                            mJealousyAlarm = AlarmManager.Global.AddAlarm(kJealousyBroadcasterDelay, TimeUnit.Minutes, StartJealousyBroadcaster, "StartJealousyBroadcaster", AlarmType.DeleteOnReset, container);
                            container.PreWooHooBehavior(Actor, Target, this);
                            mCurrentStateMachine.RequestState(false, "x", "WooHoo");
                            mCurrentStateMachine.RequestState(true, "y", "WooHoo");
                            container.PostWooHooBehavior(Actor, Target, this);
                            Relationship.Get(Actor, Target, true).STC.Update(Actor, Target, CommodityTypes.Amorous, kSTCIncreaseAfterWoohoo);

                            if (CanSleep(Actor, container))
                            {
                                SleepAfter = true;
                            }
                            else
                            {
                                SleepAfter = false;
                                container.PartComp.GetPartSimIsIn(Actor).BedMade = true;
                            }

                            if (CanSleep(Target, container))
                            {
                                (LinkedInteractionInstance as WooHoo).SleepAfter = true;
                            }
                            else
                            {
                                (LinkedInteractionInstance as WooHoo).SleepAfter  = false;
                                container.PartComp.GetPartSimIsIn(Target).BedMade = true;
                            }

                            /*
                             * if (SleepAfter)
                             * {
                             *  mCurrentStateMachine.RequestState(null, "ToSleep");
                             * }
                             * else*/
                            {
                                mCurrentStateMachine.RequestState(null, "ToRelax");
                            }

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

                            if (container is BedDoubleHover)
                            {
                                Actor.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed);
                                Target.BuffManager.AddElement(BuffNames.MeterHighClub, Origin.FromWooHooOnHoverBed);
                            }

                            if (container is BedDreamPod)
                            {
                                Actor.BuffManager.AddElement(BuffNames.DoubleDreaming, Origin.FromWooHooInDreamPod);
                                Target.BuffManager.AddElement(BuffNames.DoubleDreaming, Origin.FromWooHooInDreamPod);
                            }
                        }

                        FinishSocial(CommonSurrogate.GetSocialName(definition.GetStyle(this)), true);
                        CleanupSituation();
                        Actor.AddExitReason(ExitReason.Finished);
                    }
                    else
                    {
                        container = Target.Posture.Container as BedMultiPart;

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

                        PartComponent <BedData> partComp = container.PartComp;

                        if (partComp.GetSimInOtherPart(Target) == null)
                        {
                            int     num;
                            BedData otherPart = partComp.GetOtherPart(partComp.GetPartSimIsIn(Target));

                            if (!Actor.RouteToSlotListAndCheckInUse(container, otherPart.RoutingSlot, out num))
                            {
                                Actor.AddExitReason(ExitReason.RouteFailed);
                                return(false);
                            }

                            Actor.SynchronizationLevel = Sim.SyncLevel.Routed;

                            if (Rejected)
                            {
                                Actor.PlaySoloAnimation("a2a_bed_relax_cuddle_reject_standing_y", true);
                                Actor.RouteAway(kMinDistanceToMoveAwayWhenRejected, kMaxDistanceToMoveAwayWhenRejected, true,
                                                new InteractionPriority(InteractionPriorityLevel.Zero), false, true, true, RouteDistancePreference.NoPreference);

                                return(true);
                            }

                            if (!otherPart.RelaxOnBed(Actor, "Enter_BedRelax_" + otherPart.StateNameSuffix))
                            {
                                return(false);
                            }
                        }
                        else
                        {
                            Actor.SynchronizationLevel = Sim.SyncLevel.Routed;
                        }

                        DoLoop(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached));

                        if (!Actor.HasExitReason(ExitReason.Finished))
                        {
                            PostLoop();
                            WaitForMasterInteractionToFinish();
                        }
                    }

                    PostLoop();
                    WaitForSyncComplete();

                    succeeded = !Failed && !Rejected;
                }
                finally
                {
                    EndCommodityUpdates(succeeded);
                    StandardExit(false, false);
                }

                if (succeeded)
                {
                    VisitSituation situation  = VisitSituation.FindVisitSituationInvolvingGuest(Actor);
                    VisitSituation situation2 = VisitSituation.FindVisitSituationInvolvingGuest(Target);

                    if (situation != null && situation2 != null)
                    {
                        situation.GuestStartingInappropriateAction(Actor, 3.5f);
                        situation2.GuestStartingInappropriateAction(Target, 3.5f);
                    }
                }

                if (succeeded && SleepAfter)
                {
                    if (!Actor.InteractionQueue.HasInteractionOfType(BedSleep.Singleton))
                    {
                        InteractionInstance instance = BedSleep.Singleton.CreateInstance(container, Actor, GetPriority(), Autonomous, CancellableByPlayer);
                        Actor.InteractionQueue.PushAsContinuation(instance, true);
                    }

                    if (VisitSituation.FindVisitSituationInvolvingGuest(Target) != null && Actor.IsAtHome)
                    {
                        SocialCallback.OnStayOver(Actor, Target, false);
                    }
                    else if (VisitSituation.FindVisitSituationInvolvingGuest(Actor) != null && Target.IsAtHome)
                    {
                        SocialCallback.OnStayOver(Target, Actor, false);
                    }
                }
                else if (!IsOwner(Actor, container))
                {
                    InteractionInstance instance = Actor.Posture.GetStandingTransition();

                    if (instance != null)
                    {
                        Actor.InteractionQueue.Add(instance);
                    }
                }

                return(succeeded);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Woohooer.Settings.AddChange(Actor);
                Woohooer.Settings.AddChange(Target);
                Common.Exception(Actor, Target, e);

                return(false);
            }
        }
示例#15
0
        public override bool Run()
        {
            try
            {
                if ((Book == null) || Book.HasBeenDestroyed)
                {
                    return(false);
                }

                Book.AddToReferenceList(Actor);
                mAddedToReferenceList = true;
                InteractionDefinition readToSleepSingleton   = null;
                InteractionDefinition beReadToSleepSingleton = null;

                // Custom
                IReadToSleepObject myBed = Target.Bed as IReadToSleepObject;
                if (myBed != null)
                {
                    if (myBed.TestReadToSleep(Actor, Target))
                    {
                        readToSleepSingleton   = myBed.GetReadToSleepSingleton();
                        beReadToSleepSingleton = myBed.GetBeReadToSleepSingleton();
                    }
                }

                if (beReadToSleepSingleton == null)
                {
                    for (int i = 0; i < 2; i++)
                    {
                        foreach (IReadToSleepObject obj2 in Target.LotCurrent.GetObjects <IReadToSleepObject>())
                        {
                            if ((i == 0) && (myBed != null))
                            {
                                if (myBed.RoomId != obj2.RoomId)
                                {
                                    continue;
                                }
                            }

                            if (obj2.TestReadToSleep(Actor, Target))
                            {
                                readToSleepSingleton   = obj2.GetReadToSleepSingleton();
                                beReadToSleepSingleton = obj2.GetBeReadToSleepSingleton();
                                break;
                            }
                        }

                        if (beReadToSleepSingleton != null)
                        {
                            break;
                        }
                    }
                }

                if ((readToSleepSingleton == null) && (beReadToSleepSingleton == null))
                {
                    return(false);
                }
                InteractionInstance entry = null;
                if (beReadToSleepSingleton != null)
                {
                    entry = beReadToSleepSingleton.CreateInstanceWithCallbacks(Actor, Target, GetPriority(), Autonomous, CancellableByPlayer, new Callback(OnChildStarted), new Callback(OnChildCompleted), new Callback(OnChildFailed));
                    entry.LinkedInteractionInstance = this;
                    if (!Target.InteractionQueue.Add(entry))
                    {
                        return(false);
                    }
                }
                if (Book.InInventory)
                {
                    if (!Actor.Inventory.Contains(Book))
                    {
                        IGameObject closestBookshelf;
                        Bookshelf_GetBook.Definition definition3 = new Bookshelf_GetBook.Definition(Book);
                        if (kAlwaysUseClosestBookshelf && (ClosestBookshelf != null))
                        {
                            closestBookshelf = ClosestBookshelf;
                        }
                        else
                        {
                            closestBookshelf = Book.ItemComp.InventoryParent.Owner;
                        }
                        if (!definition3.CreateInstance(closestBookshelf, Actor, GetPriority(), Autonomous, CancellableByPlayer).RunInteraction())
                        {
                            return(false);
                        }
                    }
                }
                else
                {
                    if (!CarrySystem.PickUp(Actor, Book))
                    {
                        return(false);
                    }
                    if (!CarrySystem.PutInSimInventory(Actor))
                    {
                        return(false);
                    }
                }

                if (!Actor.Inventory.Contains(Book))
                {
                    return(false);
                }

                if (Actor.HasExitReason(~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached)))
                {
                    return(false);
                }

                LinkedInteractionInstance = null;
                InteractionInstance instance = readToSleepSingleton.CreateInstance(Target, Actor, GetPriority(), Autonomous, CancellableByPlayer);
                instance.LinkedInteractionInstance = entry;
                (instance as IReadToSleepInteraction).ReservedBook = Book;
                return(Actor.InteractionQueue.PushAsContinuation(instance, true));
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }