示例#1
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);
        }
示例#2
0
文件: SaunaSit.cs 项目: yakoder/NRaas
        public override bool Run()
        {
            try
            {
                SitData        data2;
                Slot           slot2;
                object         obj2;
                SittingPosture posture2;
                ISittable      sittable = SittingHelpers.CastToSittable(Target);
                if (sittable == null)
                {
                    Actor.AddExitReason(ExitReason.FailedToStart);
                    return(false);
                }

                Slot containmentSlotClosestToHit = GetContainmentSlotClosestToHit();
                if (Actor.Posture.Container == Target)
                {
                    SittingPosture posture = Actor.Posture as SittingPosture;
                    if (posture != null)
                    {
                        SitData target = posture.Part.Target;
                        if (containmentSlotClosestToHit == target.ContainmentSlot)
                        {
                            return(true);
                        }
                        if (!Stand.Singleton.CreateInstance(Target, Actor, GetPriority(), Autonomous, CancellableByPlayer).RunInteraction())
                        {
                            return(false);
                        }
                    }
                }

                SimQueue simLine = Target.SimLine;
                if ((simLine != null) && !simLine.WaitForTurn(this, SimQueue.WaitBehavior.DontPlayRouteFail | SimQueue.WaitBehavior.NeverWait, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), 0f))
                {
                    Sim firstSim = simLine.FirstSim;
                    if ((firstSim != null) && (firstSim.InteractionQueue.TransitionInteraction is Stand))
                    {
                        Actor.RemoveExitReason(ExitReason.ObjectInUse);
                        simLine.WaitForTurn(this, SimQueue.WaitBehavior.DontPlayRouteFail | SimQueue.WaitBehavior.OnlyWaitAtHeadOfLine, ~(ExitReason.Replan | ExitReason.MidRoutePushRequested | ExitReason.ObjectStateChanged | ExitReason.PlayIdle | ExitReason.MaxSkillPointsReached), kTimeToWait);
                    }
                }

                if (!sittable.RouteToForSitting(Actor, containmentSlotClosestToHit, true, out data2, out slot2, out obj2))
                {
                    return(false);
                }

                sittable = SittingHelpers.CastToSittable(data2.Container);
                if (!SittingHelpers.ReserveSittable(this, Actor, sittable, data2))
                {
                    return(false);
                }

                StateMachineClient smc = sittable.StateMachineAcquireAndInit(Actor);
                if (smc == null)
                {
                    Actor.AddExitReason(ExitReason.NullValueFound);
                    SittingHelpers.UnreserveSittable(this, sittable, data2);
                    return(false);
                }

                ISittingPostureCreator parent = data2.Container.Parent as ISittingPostureCreator;
                if (parent != null)
                {
                    posture2 = parent.CreatePosture(data2.Container, Actor, smc, data2);
                }
                else
                {
                    posture2 = new SittingPosture(data2.Container, Actor, smc, data2);
                }

                if (smc.HasActorDefinition("surface"))
                {
                    smc.SetActor("surface", data2.Container);
                }

                BeginCommodityUpdates();
                Actor.LookAtManager.DisableLookAts();
                bool flag = (Actor.CarryStateMachine != null) && (Actor.GetObjectInRightHand() is IUseCarrySitTransitions);
                if (flag)
                {
                    Actor.CarryStateMachine.RequestState(false, "x", "CarrySitting");
                }

                Definition definition = InteractionDefinition as Definition;
                if (!SaunaClassicEx.StateMachineEnterAndSit(sittable as SaunaClassic, definition.mForWoohoo, smc, posture2, slot2, obj2))
                {
                    if (flag)
                    {
                        Actor.CarryStateMachine.RequestState(false, "x", "Carry");
                    }
                    Actor.LookAtManager.EnableLookAts();
                    Actor.AddExitReason(ExitReason.NullValueFound);
                    SittingHelpers.UnreserveSittable(this, sittable, data2);
                    EndCommodityUpdates(false);
                    return(false);
                }

                Actor.LookAtManager.EnableLookAts();
                Actor.Posture = posture2;
                if (sittable.ComfyScore > 0x0)
                {
                    Actor.BuffManager.AddElement(BuffNames.Comfy, sittable.ComfyScore, Origin.FromComfyObject);
                }

                EndCommodityUpdates(true);
                StandardExit(false, false);
                if (Actor.HasExitReason(ExitReason.UserCanceled))
                {
                    Actor.AddExitReason(ExitReason.CancelledByPosture);
                }

                if (mIsMaster)
                {
                    SaunaSit linked = LinkedInteractionInstance as SaunaSit;
                    if (linked != null)
                    {
                        Sim linkedActor = linked.Actor;

                        while (!Cancelled)
                        {
                            if (!linkedActor.InteractionQueue.HasInteraction(linked))
                            {
                                break;
                            }

                            if (linked.mCompleted)
                            {
                                break;
                            }

                            SpeedTrap.Sleep(10);
                        }
                    }
                }

                return(!Actor.HasExitReason());
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(Actor, Target, e);
                return(false);
            }
        }
示例#3
0
 public SitTask(SitData sitData)
 {
     _sitData = sitData;
 }
示例#4
0
        public static EatingPosture GetPostureParam(Sim sim)
        {
            IEdible target = (IEdible)RandomUtil.GetRandomObjectFromList(Recipe.Recipes);

            if (sim.Posture.Satisfies(CommodityKind.Standing, target))
            {
                return(EatingPosture.standing);
            }
            if (sim.Posture.Satisfies(CommodityKind.Sitting, target))
            {
                SitData        sitData        = null;
                SittingPosture sittingPosture = sim.Posture as SittingPosture;
                if (sittingPosture != null)
                {
                    sitData = sittingPosture.Part.Target;
                }
                else
                {
                    ISittable sittable = SittingHelpers.CastToSittable(sim.Posture.Container as GameObject);
                    if (sittable != null)
                    {
                        PartData partSimIsIn = sittable.PartComponent.GetPartSimIsIn(sim);
                        sitData = (partSimIsIn as SitData);
                    }
                }
                if (sitData != null)
                {
                    switch (sitData.SitStyle)
                    {
                    case SitStyle.Dining:
                    {
                        if (target.Parent != sim)
                        {
                            return(EatingPosture.diningIn);
                        }
                        return(EatingPosture.diningOut);
                    }

                    case SitStyle.Living:
                    {
                        if (target is HotBeverageMachine.Cup)
                        {
                            return(EatingPosture.living);
                        }
                        if (target.Parent != sim)
                        {
                            return(EatingPosture.diningIn);
                        }
                        return(EatingPosture.diningOut);
                    }

                    case SitStyle.Stool:
                    {
                        if (target.Parent != sim)
                        {
                            return(EatingPosture.barstoolIn);
                        }
                        return(EatingPosture.barstoolOut);
                    }
                    }
                }
                return(EatingPosture.diningOut);
            }
            return(EatingPosture.standing);
        }