Exemple #1
0
        public override bool Run()
        {
            bool result = false;

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

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

            skillActor = Actor.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillActor == null)
            {
                skillActor = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                             as EWPetFightingSkill;
                if (skillActor == null)
                {
                    return(false);
                }
            }

            skillTarget = Target.SkillManager.GetSkill <EWPetFightingSkill>(EWPetFightingSkill.skillNameID);
            if (skillTarget == null)
            {
                skillTarget = Actor.SkillManager.AddElement(EWPetFightingSkill.skillNameID)
                              as EWPetFightingSkill;
                if (skillTarget == null)
                {
                    return(false);
                }
            }

            skillActor.StartSkillGain(skillActor.getSkillGainRate(Actor));
            skillTarget.StartSkillGain(skillTarget.getSkillGainRate(Target));

            BeginCommodityUpdates();
            Actor.RequestWalkStyle(WalkStyle.PetRun);

            if (!BeginSocialInteraction(new SocialInteractionB.Definition(null, GetInteractionName(),
                                                                          allowCarryChild: false), pairedSocial: true, doCallOver: false))
            {
                if (Actor.IsCat)
                {
                    Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                    PouncePosture pouncePosture2 = Actor.Posture as PouncePosture;
                    if (pouncePosture2 != null)
                    {
                        pouncePosture2.ExitPounce();
                        Actor.PopPosture();
                    }
                }
                else
                {
                    Actor.UnrequestWalkStyle(WalkStyle.PetRun);
                }
                EndCommodityUpdates(false);
                return(false);
            }

            Actor.UnrequestWalkStyle(WalkStyle.PetRun);

            if (Actor.IsCat)
            {
                PouncePosture pouncePosture = PouncePosture.Create(Actor);
                pouncePosture.EnterPounce();
                Actor.Posture = pouncePosture;
            }

            StandardEntry(addToUseList: false);
            StartSocial("Fight Pet");
            ((SocialInteraction)LinkedInteractionInstance).Rejected = Rejected;
            mPetFightNoiseBroadcast = new ReactionBroadcaster(Actor, kPetFightLoudBroadcastParams,
                                                              FightBroadcastCallback);
            PetStartleBehavior.CheckForStartle(Actor, StartleType.Fight);
            EnterStateMachine("PetFight", "Enter", "x");
            SetActor("y", Target);
            AnimateSim("Loop Fight");
            // TODO: A fight should reduce fatigue
            InteractionTuning tuning = InteractionObjectPair.Tuning;

            if (tuning != null && tuning.mTradeoff != null)
            {
                using (List <CommodityChange> .Enumerator enumerator = tuning.mTradeoff.mOutputs.GetEnumerator())
                {
                    if (enumerator.MoveNext())
                    {
                        CommodityChange current = enumerator.Current;
                        if (current.Commodity == CommodityKind.CatScratch)
                        {
                            LinkedInteractionInstance.BeginCommodityUpdate(current, 1f);
                        }
                    }
                }
            }

            bool success = DoTimedLoop(RandomUtil.GetFloat(kPetFightTimeMinMax[0], kPetFightTimeMinMax[1]),
                                       ExitReason.Default);

            EndCommodityUpdates(success);
            Actor.Motives.SetValue(CommodityKind.Energy, Actor.Motives.GetMotiveValue(CommodityKind.Energy - 200));
            LinkedInteractionInstance.EndCommodityUpdates(success);
            bool actorWon = DoesActorWinFight();

            if (!actorWon)
            {
                AnimateSim("Swap");
                SetActor("x", Target);
                SetActor("y", Actor);
                skillTarget.wonFight(Actor, Target.LotCurrent == Target.LotHome);
                skillActor.lostFight(Target);
                skillTarget.AddPoints(200f, true, true);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightLose",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessageNegative);
            }
            else
            {
                skillActor.wonFight(Target, Actor.LotCurrent == Actor.LotHome);
                skillTarget.lostFight(Actor);
                Actor.ShowTNSIfSelectable(Localization.LocalizeString("Echoweaver/PetFighting/EWFightPet:PetFightWin",
                                                                      Actor.Name), StyledNotification.NotificationStyle.kGameMessagePositive);
            }
            AnimateSim("Exit");

            if (Actor.IsCat)
            {
                Actor.UnrequestWalkStyle(WalkStyle.CatStalk);
                if (Actor.Posture is PouncePosture)
                {
                    Actor.PopPosture();
                }
            }
            else
            {
                Actor.UnrequestWalkStyle(WalkStyle.PetRun);
            }

            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Actor, Target, "Fight Pet", wasRecipient: false, wasAccepted: true, actorWon, CommodityTypes.Undefined));
            EventTracker.SendEvent(new SocialEvent(EventTypeId.kSocialInteraction, Target, Actor, "Fight Pet", wasRecipient: true, wasAccepted: true, !actorWon, CommodityTypes.Undefined));

            if (mPetFightNoiseBroadcast != null)
            {
                mPetFightNoiseBroadcast.EndBroadcast();
                mPetFightNoiseBroadcast = null;
            }
            FinishSocial("Fight Pet", bApplySocialEffect: true);
            skillActor.StopSkillGain();
            skillTarget.StopSkillGain();
            FinishLinkedInteraction();
            WaitForSyncComplete();
            StandardExit(removeFromUseList: false);

            LikingChange();

            // Check for death conditions BEFORE new wounds assigned
            CheckForDeath(actorWon);
            AssignFightWounds();

            // If this is called from ChaseOffLot, then the target will flee if it loses
            if (!actorWon && actorRunOnLose && Actor.LotCurrent != Actor.LotHome)
            {
                Actor.PopPosture();
                Actor.RequestWalkStyle(WalkStyle.PetRun);
                MakeSimGoHome(Actor, false);
            }
            else if (actorWon && targetRunOnLose && Target.LotCurrent != Target.LotHome)
            {
                Target.PopPosture();
                if (Target.IsHuman)
                {
                    Target.RequestWalkStyle(WalkStyle.MeanChasedRun);
                }
                else
                {
                    Target.RequestWalkStyle(WalkStyle.PetRun);
                }
                MakeSimGoHome(Target, false);
            }

            return(success);
        }