Exemplo n.º 1
0
                public override bool Test(Sim a, JapLowDinnerTable target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
                {
                    ObjectGuid containedObject = Slots.GetContainedObject(target.ObjectId, 2820733094u);

                    if (containedObject == ObjectGuid.InvalidObjectGuid)
                    {
                        return(false);
                    }
                    PreparedFood preparedFood = containedObject.ObjectFromId <PreparedFood>();

                    if (!JapLowDinnerTable.CheckIfHasFood(preparedFood))
                    {
                        return(false);
                    }
                    if (!JapLowDinnerTable.kServeOrEatSpoiledFood && preparedFood.IsSpoiled)
                    {
                        return(false);
                    }
                    if (JapLowDinnerTable.kOnlyRecipesThatUseFork && (preparedFood.CookingProcess == null || preparedFood.CookingProcess.Recipe == null || preparedFood.CookingProcess.Recipe.Utensil != "fork"))
                    {
                        return(false);
                    }
                    if (!JapLowDinnerTable.kServeOrEatBurntFood && preparedFood.CookingProcess != null && preparedFood.CookingProcess.FoodState == FoodCookState.Burnt)
                    {
                        return(false);
                    }
                    if (target.ActorsUsingMe.Contains(a))
                    {
                        return(false);
                    }
                    if (target.InUse && target.ActorsUsingMe.Count >= 4)
                    {
                        greyedOutTooltipCallback = InteractionInstance.CreateTooltipCallback("No Free Spots");
                        return(false);
                    }
                    if (isAutonomous)
                    {
                        if (a.SimDescription.IsRobot)
                        {
                            return(false);
                        }
                        if (a.BuffManager.HasElement(BuffNames.Stuffed))
                        {
                            return(false);
                        }
                    }
                    return(true);
                }
Exemplo n.º 2
0
        /*
         * public static void DebugMsg(Sim sim, Common.StringBuilder msg, string text)
         * {
         *  if (text != null)
         *  {
         *      msg += Common.NewLine + text;
         *  }
         *
         *  if ((sim != null) && (sim.FirstName == "Roberto"))
         *  {
         *      Common.Notify(msg);
         *  }
         * }
         */
        public override bool DoRoute(Route r)
        {
            Sim routeSim = null;

            if (!GoHere.Settings.mAllowCarRouting)
            {
                r.SetOption(Route.RouteOption.EnablePlanningAsCar, false);
                r.SetOption(Route.RouteOption.BeginAsCar, false);
            }

            Common.StringBuilder msg = new Common.StringBuilder("DoRoute");

            try
            {
                if (r.Follower != null)
                {
                    routeSim = r.Follower.Target as Sim;
                }

                if (!GoHere.Settings.mAllowBoatRouting)
                {
                    Houseboat boat;
                    if (!Houseboat.IsPointOnHouseboat(mOwnerSim.Position, out boat))
                    {
                        r.SetOption2(Route.RouteOption2.EnablePlanningAsBoat, false);
                        r.SetOption2(Route.RouteOption2.BeginAsBoat, false);
                        r.SetOption2(Route.RouteOption2.EndAsBoat, false);

                        bool water = false;
                        if (mOwnerSim.InteractionQueue != null)
                        {
                            Terrain.GoHere interaction = mOwnerSim.InteractionQueue.GetHeadInteraction() as Terrain.GoHere;

                            if (interaction != null && interaction.mDestinationType == Terrain.GoHere.DestinationType.OnSeaWater)
                            {
                                water = true;
                            }
                        }

                        if (mOwnerSim.Posture is Ocean.PondAndOceanRoutingPosture || mOwnerSim.Posture is SwimmingInPool)
                        {
                            water = true;
                        }

                        if (water)
                        {
                            r.SetOption(Route.RouteOption.EnableWaterPlanning, true);
                            r.SetOption(Route.RouteOption.DoNotEmitDegenerateRoutesForRadialRangeGoals, true);
                            r.SetOption(Route.RouteOption.DisallowGoalsOnBridges, true);
                        }
                    }
                }

                if (!GoHere.Settings.mAllowMermaidRouting)
                {
                    r.SetOption2(Route.RouteOption2.RouteAsMermaid, false);
                }

                // why did he use routeSim here? It seems to always be null...
                if ((routeSim != null) && (routeSim.Occupation != null))
                {
                    if (routeSim.SimDescription.GetOutfitCount(OutfitCategories.Career) == 0)
                    {
                        routeSim.Occupation.SetOccupationOutfitForCurrentLevel();
                    }
                }

                if (!r.PlanResult.Succeeded())
                {
                    msg += Common.NewLine + "A: " + r.PlanResult + " False";

                    DoRouteFailureBehavior(r);
                    mOwnerSim.AddExitReason(ExitReason.RouteFailed);
                    return(false);
                }

                bool        flag    = false;
                IGameObject destObj = r.DestObj as IGameObject;
                try
                {
                    if (destObj != null)
                    {
                        destObj.AddToRoutingReferenceList(mOwnerSim);
                        mOwnerSim.LookAtManager.SetRoutingLookAt(destObj as GameObject);
                    }

                    mbIgnoreAllObstaclesStartTimeValid = false;
                    if (mOwnerSim.IsActiveSim)
                    {
                        Route.SetFadePriority(mOwnerSim.ObjectId, 0x186a3);
                    }
                    else if (mOwnerSim.IsInActiveHousehold)
                    {
                        Route.SetFadePriority(mOwnerSim.ObjectId, 0x186a2);
                    }
                    else
                    {
                        Route.SetFadePriority(mOwnerSim.ObjectId, 0x186a1);
                    }

                    while (true)
                    {
                        flag = false;
                        if (mbPushRequested)
                        {
                            if ((!(mOwnerSim.Posture is SittingInVehicle) && !(mOwnerSim.Posture is SittingInBoat)) && (mOwnerSim.RoutingComponent.RoutingParent == null))
                            {
                                try
                                {
                                    MidRouteBePushed(r.ExecutionFromNonSimTaskIsSafe);
                                }
                                catch (ResetException)
                                {
                                    throw;
                                }
                                catch (Exception e)
                                {
                                    Common.Exception(routeSim, e);
                                }

                                r.Replan();
                            }
                            else
                            {
                                mbPushRequested = false;
                            }

                            continue;
                        }

                        StartPushImmunity(OnRouteStartedImmuneToPushesDuration);
                        flag  = DoSingleRouteEx(r, true);
                        flag &= r.PlanResult.Succeeded();
                        if (mbPushRequested)
                        {
                            continue;
                        }

                        if (r.GetOption(Route.RouteOption.CheckForFootprintsNearGoals))
                        {
                            ObjectGuid guid = r.IsPointObstructedBySim(mOwnerSim.PositionOnFloor);
                            if (guid != ObjectGuid.InvalidObjectGuid)
                            {
                                ObjectGuid runningTargetId = ObjectGuid.InvalidObjectGuid;
                                if (((mOwnerSim.InteractionQueue != null) && (mOwnerSim.InteractionQueue.RunningInteraction != null)) && (mOwnerSim.InteractionQueue.RunningInteraction.Target != null))
                                {
                                    runningTargetId = mOwnerSim.InteractionQueue.RunningInteraction.Target.ObjectId;
                                }

                                if ((guid != runningTargetId) && !PushSims(mOwnerSim.PositionOnFloor, 0.5f, false))
                                {
                                    bool option = r.GetOption(Route.RouteOption.BlockedByPeople);
                                    r.SetOption(Route.RouteOption.BlockedByPeople, true);
                                    r.Replan();
                                    r.SetOption(Route.RouteOption.BlockedByPeople, option);
                                    if (r.PlanResult.Succeeded() && (r.IsPointObstructedBySim(mOwnerSim.PositionOnFloor) == ObjectGuid.InvalidObjectGuid))
                                    {
                                        continue;
                                    }

                                    StartPushImmunity(OnEmergencyGetAwayRouteStartedImmuneToPushesDuration);
                                    Route route = PlanRouteForPush(mOwnerSim, null, PushSimsAwayDistanceMin, PushSimsAwayDistanceMax);
                                    DoSingleRouteEx(route, false);
                                    flag = false;
                                    if (r.DoRouteFail)
                                    {
                                        Sim sim = guid.ObjectFromId <Sim>();
                                        PlayRouteFailureIfAppropriate(sim);
                                    }

                                    RouteFailureTurnJigBlocker = ObjectGuid.InvalidObjectGuid;
                                    HasRouteFailureFromTurnJig = false;

                                    msg += Common.NewLine + "B: " + r.PlanResult + " " + flag;

                                    return(flag);
                                }
                            }
                        }

                        break;
                    }

                    if (HasRouteFailureFromTurnJig && r.DoRouteFail)
                    {
                        GameObject obj3 = GameObject.GetObject(RouteFailureTurnJigBlocker);
                        PlayRouteFailureIfAppropriate(obj3);
                    }
                }
                finally
                {
                    if (destObj != null)
                    {
                        destObj.RemoveFromRoutingReferenceList(mOwnerSim);
                    }

                    mbIgnoreAllObstaclesStartTimeValid = false;
                    mbPushImmunityStartTimeValid       = false;
                    Route.SetFadePriority(mOwnerSim.ObjectId, 0x186a0);
                    mOwnerSim.LookAtManager.SetRoutingLookAt(null);
                }

                RouteFailureTurnJigBlocker = ObjectGuid.InvalidObjectGuid;
                HasRouteFailureFromTurnJig = false;

                msg += Common.NewLine + "C: " + flag;

                return(flag);
            }
            catch (ResetException)
            {
                throw;
            }
            catch (Exception e)
            {
                Common.Exception(routeSim, e);
                throw;
            }
            finally
            {
                //Common.DebugNotify(msg, routeSim);
            }
        }
Exemplo n.º 3
0
            public override bool Run()
            {
                int num = -1;

                if (!JapLowDinnerTable.FindClosestFreeSlot(this.Actor, this.Target, out num))
                {
                    return(false);
                }
                ObjectGuid containedObject = Slots.GetContainedObject(this.Target.ObjectId, 2820733094u);

                if (containedObject == ObjectGuid.InvalidObjectGuid)
                {
                    return(false);
                }
                this.mServingContainer = containedObject.ObjectFromId <PreparedFood>();
                if (this.mServingContainer == null || !JapLowDinnerTable.CheckIfHasFood(this.mServingContainer))
                {
                    return(false);
                }
                this.mServingContainer.AddToUseList(this.Actor);
                if (this.Actor.HasTrait(TraitNames.Slob))
                {
                    this.mEatingDuration = JapLowDinnerTable.kMealDurationSlobTrait;
                }
                else
                {
                    this.mEatingDuration = JapLowDinnerTable.kMealDuration;
                }
                if (JapLowDinnerTable.kEnableGroupTalkWhileEating)
                {
                    this.mEatingDuration += JapLowDinnerTable.kGroupTalkMealDurationExtra;
                }
                this.mLastReactionTime = SimClock.ElapsedTime(TimeUnit.Minutes);
                base.StandardEntry();
                base.BeginCommodityUpdates();
                base.AcquireStateMachine("ArsilSeiza");
                base.SetActor("x", this.Actor);
                base.EnterState("x", "Enter");
                base.AnimateSim("Idle");
                if (!this.Target.ChangeIntoOutfit(this.Actor))
                {
                    base.AnimateSim("Exit");
                    this.Actor.PlayReaction(ReactionTypes.Shrug, ReactionSpeed.Immediate);
                    base.StandardExit();
                    return(false);
                }
                Simulator.Sleep(1u);
                bool isSufficientlyFullForStuffed = false;
                bool hasFatDelta = false;

                Food.PreEat(this.Actor, this.mServingContainer, ref isSufficientlyFullForStuffed, ref hasFatDelta);
                base.AnimateSim("PreEat");
                base.AnimateSim("Eat");
                bool result = this.DoLoop(ExitReason.Default, new InteractionInstance.InsideLoopFunction(this.LoopCallback), this.mCurrentStateMachine);

                base.AnimateSim("PostEat");
                if (this.mServingContainer != null && this.mServingContainer.ActorsUsingMe.Contains(this.Actor))
                {
                    this.mServingContainer.ActorsUsingMe.Remove(this.Actor);
                }
                this.Actor.SwitchToPreviousOutfitWithoutSpin();
                base.AnimateSim("Idle");
                base.AnimateSim("Exit");
                Food.PostEat(this.Actor, this.mServingContainer, isSufficientlyFullForStuffed, true, hasFatDelta);
                base.StandardExit();
                return(result);
            }