Example #1
0
        protected void reset(Expression expression)
        {
            ResetTask task = new ResetTask(this, expression);

            SqlTable.AddQueue(task);
            task.Wait();
        }
Example #2
0
        protected void reset(Expression <Func <modelType, bool> > expression)
        {
            ResetTask task = new ResetTask(this, expression);

            SqlTable.AddQueue(task);
            task.Wait();
        }
Example #3
0
        protected static void OnPostPlan(Route r, string routeType, string result)
        {
            Sim sim = null;

            try
            {
                if (!Overwatch.Settings.mStuckCheckV2)
                {
                    return;
                }

                if ((r != null) && (r.Follower != null))
                {
                    sim = r.Follower.Target as Sim;
                    if ((sim != null) && (sim.SimDescription != null))
                    {
                        StuckSimData other;
                        if (!sRouteData.TryGetValue(sim.SimDescription.SimDescriptionId, out other))
                        {
                            other = new StuckSimData();

                            sRouteData.Add(sim.SimDescription.SimDescriptionId, other);
                        }

                        if (other.mInReset)
                        {
                            return;
                        }

                        if (other.mLastPosition != sim.Position)
                        {
                            other.mLastPosition = sim.Position;
                            other.mChecks       = 0;
                        }
                        else if (!r.PlanResult.Succeeded())
                        {
                            if (other.mChecks == 0)
                            {
                                other.mLastPositionTicks = SimClock.CurrentTicks;
                            }

                            other.mChecks++;

                            if (other.mChecks > Overwatch.Settings.mMinimumRouteFail)
                            {
                                if ((SimClock.CurrentTicks - other.mLastPositionTicks) > (SimClock.kSimulatorTicksPerSimMinute * Overwatch.Settings.mRouteFailTestMinutesV2))
                                {
                                    sTracer.Perform();

                                    if (!sTracer.mIgnore)
                                    {
                                        if (Common.kDebugging)
                                        {
                                            Common.DebugStackLog("OnPostPlan" + Common.NewLine + sim.FullName + Common.NewLine + r.PlanResult + Common.NewLine + other.mChecks);
                                            Common.DebugNotify("OnPostPlan" + Common.NewLine + sim.FullName + Common.NewLine + r.PlanResult + Common.NewLine + other.mChecks, sim);
                                        }
                                    }

                                    other.mChecks = 0;

                                    if (!sTracer.mIgnore)
                                    {
                                        other.mInReset = true;

                                        ResetTask.Perform(sim, r.GetDestPoint(), "Unroutable");
                                    }
                                }
                            }
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(sim, null, "OnPostPlan", e);
            }
        }
Example #4
0
        protected override void PrivatePerformAction(bool prompt)
        {
            Overwatch.Log(Name);

            foreach (Sim createdSim in new List <Sim> (LotManager.Actors))
            {
                StuckSimData other;
                if (!sData.TryGetValue(createdSim.SimDescription.SimDescriptionId, out other))
                {
                    other = new StuckSimData();

                    sData.Add(createdSim.SimDescription.SimDescriptionId, other);
                }

                try
                {
                    bool wasReset = false;

                    if ((createdSim != null) && (createdSim.InWorld) && (createdSim.Proxy != null) && (!SimTypes.IsSelectable(createdSim)))
                    {
                        bool check = true;

                        if (createdSim.Parent is IBed)
                        {
                            check = false;
                        }

                        if (createdSim.OccultManager != null)
                        {
                            OccultRobot bot = createdSim.OccultManager.GetOccultType(Sims3.UI.Hud.OccultTypes.Robot) as OccultRobot;

                            if (bot != null && bot.IsShutdown)
                            {
                                check = false;
                            }
                        }

                        if (check)
                        {
                            InteractionInstance interaction = createdSim.CurrentInteraction;

                            bool sameInteraction = (object.ReferenceEquals(other.mLastInteraction, interaction));

                            other.mLastInteraction = interaction;

                            if (createdSim.LotCurrent.IsRoomHidden(createdSim.RoomId))
                            {
                                ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable");
                                wasReset = true;
                            }

                            if ((!wasReset) && (other.mLastPosition != Vector3.Invalid) && (other.mLastPosition == createdSim.Position))
                            {
                                if ((interaction == null) || (sameInteraction))
                                {
                                    bool success = false;

                                    try
                                    {
                                        success = SimEx.IsPointInLotSafelyRoutable(createdSim, createdSim.LotCurrent, createdSim.PositionOnFloor);
                                    }
                                    catch (Exception e)
                                    {
                                        Common.DebugException(createdSim, e);
                                        success = false;
                                    }

                                    if (!success)
                                    {
                                        ResetTask.Perform(createdSim, Vector3.Invalid, "Unroutable");
                                        wasReset = true;
                                    }
                                }
                            }

                            if (other.mLastPosition != createdSim.Position)
                            {
                                other.mLastPosition      = createdSim.Position;
                                other.mLastPositionTicks = SimClock.CurrentTicks;
                            }
                            else if ((prompt) || ((other.mLastPositionTicks + SimClock.kSimulatorTicksPerSimDay) < SimClock.CurrentTicks))
                            {
                                if (!wasReset)
                                {
                                    bool reset = false;
                                    if (sameInteraction)
                                    {
                                        reset = true;
                                    }

                                    if (reset)
                                    {
                                        ResetTask.Perform(createdSim, Vector3.Invalid, "Stationary");
                                        wasReset = true;
                                    }
                                }
                            }
                        }
                    }
                    else
                    {
                        wasReset = true;
                    }

                    if (wasReset)
                    {
                        sData.Remove(createdSim.SimDescription.SimDescriptionId);
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(createdSim, e);
                }
            }
        }