Exemplo n.º 1
0
        public static void CleanUpOrOnFailureInteraction(Sim mActor, InteractionInstance i, bool stopImmediately, bool succeeded)
        {
            if (i.InteractionObjectPair == null)
            {
                return;
            }
            try
            {
                if (succeeded && !stopImmediately)
                {
                    i.CallCallbackOnCompletion(mActor);
                }
                else
                {
                    i.CallCallbackOnFailure(mActor);
                }
            }
            catch (NMAntiSpyException)
            { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
            catch (StackOverflowException)
            { mActor.mPosture = null; throw; }
            catch (ResetException)
            { throw; }
            catch (Exception)
            {
                NFinalizeDeath.CheckYieldingContext();
            }

            try
            {
                i.Cleanup();
            }
            catch (NMAntiSpyException)
            { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
            catch (StackOverflowException)
            { mActor.mPosture = null; throw; }
            catch (ResetException)
            { throw; }
            catch (Exception)
            {
                NFinalizeDeath.CheckYieldingContext();
            }
        }
Exemplo n.º 2
0
        public static bool ProcessAllInteraction(Sim actorIsCurrentTask)
        {
            if (actorIsCurrentTask == null ||
                actorIsCurrentTask.ObjectId.mValue != ScriptCore.Simulator.Simulator_GetCurrentTaskImpl() ||
                !Simulator.CheckYieldingContext(false))
            {
                return(false);
            }

            bool okI = false;
            var  sim = actorIsCurrentTask;

            NFinalizeDeath.CheckYieldingContext();

            if (Simulator.GetProxy(sim.ObjectId) == null)
            {
                NFinalizeDeath.ThrowResetException(null);
            }

            var simIQ = sim.InteractionQueue;


            try
            {
                if (sim.SimDescription == null)
                {
                    sim.mSimDescription = Create.NiecNullSimDescription(true, false, true);
                }

                if (simIQ == null)
                {
                    sim.mInteractionQueue = simIQ = new Sims3.Gameplay.ActorSystems.InteractionQueue(sim);
                }
                else
                {
                    if (simIQ.mInteractionList == null)
                    {
                        simIQ.mInteractionList = new List <InteractionInstance>();
                    }
                    else
                    {
                        while (simIQ.mInteractionList != null && niec_std.list_remove(simIQ.mInteractionList, null))
                        {
                            Simulator.Sleep(0);
                        }
                    }
                }
            }
            catch (NMAntiSpyException)
            { NFinalizeDeath.SafeForceTerminateRuntime(); }
            catch (StackOverflowException)
            { sim.mPosture = null; throw; }
            catch (ResetException)
            { throw; }
            catch
            {
                NFinalizeDeath.CheckYieldingContext();

                for (int i = 0; i < 45; i++)
                {
                    Simulator.Sleep(0);
                }
            }

            try
            {
                simIQ.mCurrentTransitionInteraction = null;
                if (!NiecHelperSituation.__acorewIsnstalled__ && simIQ.mRunningInteractions.Count != 0)
                {
                    simIQ.OnReset();
                }

                ShouldBabyOrToddler(simIQ);

                var simIQList = simIQ.mInteractionList;
                if (simIQList == null || simIQList.Count == 0)
                {
                    return(false);
                }

                var simIQListArray = simIQList.ToArray();
                for (int i = 0; i < simIQListArray.Length; i++)
                {
                    InteractionInstance inCurrentInteraction = simIQListArray[i];
                    if (inCurrentInteraction == null || inCurrentInteraction.InteractionDefinition == null)
                    {
                        while (simIQList != null && niec_std.list_remove(simIQList, null))
                        {
                            Simulator.Sleep(0);
                            simIQList = simIQ.mInteractionList;
                        }

                        if (simIQList == null)
                        {
                            break;
                        }

                        continue;
                    }

                    if (simIQList.IndexOf(inCurrentInteraction) != 0)
                    {
                        break;
                    }

                    if (simIQList == null)
                    {
                        break;
                    }

                    if (sim.mPosture != null)
                    {
                        int  num  = 4;
                        bool flag = false;
                        int  num2 = 10;

                        sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.PlayRouteFailNextTimeOnly;

                        List <InteractionObjectPair> list = new List <InteractionObjectPair>();

                        while (num > 0 && num2 > 0)
                        {
                            if (!inCurrentInteraction.Autonomous)
                            {
                                inCurrentInteraction.Target.ClearBlockTime();
                                if (sim.mPosture.Container != null)
                                {
                                    sim.mPosture.Container.ClearBlockTime();
                                }
                            }

                            sim.ClearExitReasons();

                            if (!inCurrentInteraction.Target.PreTransition(inCurrentInteraction))
                            {
                                inCurrentInteraction.PostureTransitionFailed(false);

                                sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                            }

                            InteractionInstance interactionInstance2 = null;
                            if (inCurrentInteraction.Target is IGlass && sim.SimDescription.IsBonehilda)
                            {
                                inCurrentInteraction.PosturePreconditions = null;
                            }

                            interactionInstance2 = ((inCurrentInteraction.PosturePreconditions != null || sim.Posture is IHaveCustomTransitionForNullPosturePreconditions) ? sim.Posture.GetTransition(inCurrentInteraction) : sim.Posture.GetStandingTransition());
                            if (interactionInstance2 == null)
                            {
                                num = 0;
                            }

                            else
                            {
                                if (num == 4 && (!inCurrentInteraction.Test() || (!inCurrentInteraction.IsTargetValid())))
                                {
                                    sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                                }

                                if (list.Contains(interactionInstance2.InteractionObjectPair))
                                {
                                    CleanUpOrOnFailureInteraction(sim, interactionInstance2, false, false);
                                    num--;
                                    continue;
                                }

                                list.Add(interactionInstance2.InteractionObjectPair);

                                sim.ClearExitReasons();
                                simIQ.mCurrentTransitionInteraction = interactionInstance2;
                                flag = false;

                                try
                                {
                                    if (inCurrentInteraction.Target != null && sim.LookAtManager != null && inCurrentInteraction.Target.Parent != sim)
                                    {
                                        sim.LookAtManager.SetInteractionLookAt(inCurrentInteraction.Target as GameObject, Sim.LookAtInterestingnessOfTargetWhenRunningTransition, LookAtJointFilter.HeadBones);
                                    }
                                    flag = NFinalizeDeath._RunInteractionWithoutCleanUp(interactionInstance2);
                                }
                                finally
                                {
                                    sim.ClearSynchronizationData();
                                    CleanUpOrOnFailureInteraction(sim, interactionInstance2, false, flag);
                                    simIQ.mCurrentTransitionInteraction = null;
                                }

                                if (inCurrentInteraction.Target == null || inCurrentInteraction.Target.HasBeenDestroyed)
                                {
                                    simIQ.mIsHeadInteractionLocked = false;
                                    sim.PlayRouteFailFrequency     = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(false);
                                }
                                if (flag && simIQ.GetHeadInteraction() != inCurrentInteraction)
                                {
                                    simIQ.mIsHeadInteractionLocked = false;
                                    sim.PlayRouteFailFrequency     = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(false);
                                }

                                if (flag && sim.HasExitReason(ExitReason.SuspensionRequested))
                                {
                                    RemoveQueue(false, simIQ, simIQList, sim, inCurrentInteraction);
                                    sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(false);
                                }

                                if (sim.HasExitReason(ExitReason.CancelExternal))
                                {
                                    if (!(sim.Posture is IDoNotGoToStandingOnTransitionFailed))
                                    {
                                        InteractionInstance standingTransition = sim.Posture.GetStandingTransition();
                                        if (standingTransition != null)
                                        {
                                            NFinalizeDeath.AddItemToList(simIQ.mInteractionList, standingTransition);
                                        }
                                    }
                                    inCurrentInteraction.PostureTransitionFailed(flag);

                                    sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;
                                    return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                                }

                                if (!flag)
                                {
                                    if (ShouldTimeUpdate(interactionInstance2))
                                    {
                                        interactionInstance2.Target.UpdateBlockTime();
                                    }
                                    num = 4;
                                }
                            }
                            num--;
                            num2--;
                        }

                        sim.PlayRouteFailFrequency = Sim.RouteFailFrequency.AlwaysPlayRouteFail;

                        if (sim.Posture != null && !sim.Posture.Satisfies(inCurrentInteraction.PosturePreconditions, inCurrentInteraction.Target, sim.Posture.GetRequiredCheck()))
                        {
                            return(OnFailedInCurrentInteraction(simIQ, simIQList, sim, inCurrentInteraction));
                        }
                    }


                    bool t = SCOSR.IsScriptCore2020() && NiecHelperSituation.isdgmods && NiecHelperSituation.__acorewIsnstalled__ && (inCurrentInteraction is Sim.GoToVirtualHome || inCurrentInteraction is Sim.GoToVirtualHome.GoToVirtualHomeInternal);

                    if (t || !inCurrentInteraction.Test() || (!inCurrentInteraction.IsTargetValid()))
                    {
                        niec_std.list_remove(simIQList, inCurrentInteraction);

                        if (inCurrentInteraction.Target != null)
                        {
                            if (!t)
                            {
                                try
                                {
                                    inCurrentInteraction.CallCallbackOnFailure(sim);
                                }
                                catch (NMAntiSpyException)
                                { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                                catch (StackOverflowException)
                                { sim.mPosture = null; throw; }
                                catch (ResetException)
                                { throw; }
                                catch (Exception)
                                {
                                    NFinalizeDeath.CheckYieldingContext();
                                }

                                try
                                {
                                    inCurrentInteraction.Cleanup();
                                }
                                catch (NMAntiSpyException)
                                { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                                catch (StackOverflowException)
                                { sim.mPosture = null; throw; }
                                catch (ResetException)
                                { throw; }
                                catch (Exception)
                                {
                                    NFinalizeDeath.CheckYieldingContext();
                                }
                            }
                            else
                            {
                                inCurrentInteraction.mbOnStartCalled = true;
                                inCurrentInteraction.mbOnStopCalled  = true;
                            }
                        }

                        if (sim.IsSelectable)
                        {
                            simIQ.FireQueueChanged();
                        }

                        continue;
                    }

                    if (inCurrentInteraction.InteractionObjectPair == null)
                    {
                        continue;
                    }

                    simIQ.mIsHeadInteractionLocked = true;

                    var runningInList = simIQ.mRunningInteractions;
                    if (runningInList != null)
                    {
                        runningInList.Push(inCurrentInteraction);
                    }

                    try
                    {
                        inCurrentInteraction.CallCallbackOnStart(sim);
                    }
                    catch (NMAntiSpyException)
                    { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                    catch (StackOverflowException)
                    { sim.mPosture = null; throw; }
                    catch (ResetException)
                    { throw; }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();
                    }

                    simIQ.mIsHeadInteractionActive = true;

                    try
                    {
                        if (inCurrentInteraction != null && inCurrentInteraction.Autonomous && sim.mAutonomy != null && sim.mAutonomy.IsRunningLocalAutonomy && !sim.IsActiveSim && (sim.IsSelectable || RandomUtil.GetFloat(100f) < Sim.AutonomyThoughtBalloonPercentageChance) && inCurrentInteraction.InteractionObjectPair.Tradeoff != null)
                        {
                            CommodityKind physicalOrTraitMotive = sim.Motives.GetPhysicalOrTraitMotive(inCurrentInteraction.InteractionObjectPair.Tradeoff);
                            sim.ShowBalloonForMotive(ThoughtBalloonTypes.kThoughtBalloon, ThoughtBalloonPriority.Low, ThoughtBalloonDuration.Short, ThoughtBalloonCooldown.None, ThoughtBalloonAxis.kNeutral, physicalOrTraitMotive, inCurrentInteraction.Target);
                        }
                    }
                    catch (NMAntiSpyException)
                    { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                    catch (StackOverflowException)
                    { sim.mPosture = null; throw; }
                    catch (ResetException)
                    { throw; }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();
                    }

                    sim.ClearExitReasons();

                    try
                    {
                        okI = NFinalizeDeath._RunInteractionWithoutCleanUp(inCurrentInteraction);
                        if (okI)
                        {
                            inCurrentInteraction.CallCallbackOnCompletion(sim);
                        }
                        else
                        {
                            inCurrentInteraction.CallCallbackOnFailure(sim);
                        }
                    }
                    catch (NMAntiSpyException)
                    { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
                    catch (StackOverflowException)
                    {
                        NFinalizeDeath.ThrowResetException(null);
                        throw;
                    }
                    catch (ResetException)
                    { throw; }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();
                    }


                    sim.ClearSynchronizationData();
                    NFinalizeDeath.CheckYieldingContext();

                    if (sim.HasExitReason(ExitReason.CancelledByPosture) && !sim.Posture.HasBeenCanceled)
                    {
                        sim.Posture.CancelPosture(sim);
                    }

                    if (!inCurrentInteraction.WasInUse && sim.OnlyHasExitReason(ExitReason.ObjectInUse))
                    {
                        inCurrentInteraction.WasInUse = true;
                    }

                    if (!okI && inCurrentInteraction.Target != null && ShouldTimeUpdate(inCurrentInteraction))
                    {
                        inCurrentInteraction.Target.UpdateBlockTime();
                    }

                    if (okI && inCurrentInteraction.Target != null && sim.IsSelectable)
                    {
                        EventTracker.SendEvent(new InteractionSuccessEvent(EventTypeId.kInteractionSuccess, sim, inCurrentInteraction.Target, inCurrentInteraction.InteractionObjectPair));
                    }

                    RemoveQueue(okI, simIQ, simIQList, sim, inCurrentInteraction);

                    if (inCurrentInteraction.ShouldReenque)
                    {
                        simIQ.ConsiderReenqueing(inCurrentInteraction);
                    }

                    if (Simulator.CheckYieldingContext(false))
                    {
                        simIQ.PutDownCarriedObjects(inCurrentInteraction);
                    }

                    NFinalizeDeath.CheckYieldingContext();

                    niec_std.list_remove(simIQList, inCurrentInteraction);
                    inCurrentInteraction.Cleanup();

                    NFinalizeDeath.CheckYieldingContext();

                    while (simIQList != null && niec_std.list_remove(simIQList, null))
                    {
                        NFinalizeDeath.CheckYieldingContext();
                        Simulator.Sleep(0);
                        simIQList = simIQ.mInteractionList;
                    }

                    if (simIQList == null)
                    {
                        break;
                    }

                    if (sim.IsSelectable)
                    {
                        simIQ.FireQueueChanged();
                    }

                    if (okI)
                    {
                        break;
                    }
                }
            }
            catch (NMAntiSpyException)
            { NFinalizeDeath.SafeForceTerminateRuntime(); throw; }
            catch (StackOverflowException)
            { sim.mPosture = null; throw; }

            if (simIQ.mInteractionList != null && simIQ.mInteractionList.Count == 0)
            {
                sim.QueueIdleLogic();
            }

            return(okI);
        }
Exemplo n.º 3
0
        internal static void r_internal(Sim Actor)
        {
            NiecHelperSituationPosture nhsp = null;

            if (Actor != null && !NFinalizeDeath.GameObjectIsValid(Actor.ObjectId.mValue)) //NFinalizeDeath.GetObject_internalFastO(Actor.ObjectId.mValue) == null)
            {
                nhsp           = (Actor.Posture as NiecHelperSituationPosture);
                Actor.mPosture = null;
                if (nhsp != null)
                {
                    nhsp._Actor = null;
                    nhsp.PBack  = null;
                }
            }

            if (Actor == null || Actor.ObjectId.mValue != ScriptCore.Simulator.Simulator_GetCurrentTaskImpl() || !Simulator.CheckYieldingContext(false))
            {
                return;
            }

            var     sim          = Actor;
            bool    bNeedMaxMood = false;
            Posture pBackUp      = null;

            if (sim.Posture is NiecHelperSituationPosture)
            {
                nhsp         = (sim.Posture as NiecHelperSituationPosture);
                pBackUp      = nhsp.PBack;
                bNeedMaxMood = nhsp.NeedMaxMood;
                nhsp._Actor  = null;
                if (sim.Standing is NiecHelperSituationPosture)
                {
                    sim.Standing = null;
                    sim.mPosture = null;
                    if (sim.mSimDescription != null)
                    {
                        if (sim.mSimDescription.IsPet)
                        {
                            PetStandingPosture dr = new PetStandingPosture(sim);
                            sim.PetSittingOnGround = new PetSittingOnGroundPosture(sim);
                            sim.Standing           = dr;
                            sim.Posture            = null;
                        }
                        else
                        {
                            Sim.StandingPosture dre = new Sim.StandingPosture(sim);
                            sim.Standing = dre;
                            sim.Posture  = null;
                        }
                    }
                }
                else if (nhsp.PBack != null)
                {
                    sim.mPosture = nhsp.PBack;//sim.Standing;
                }
                else
                {
                    sim.mPosture = sim.Standing;
                }

                nhsp.PBack = null;
            }

            if (Disallowr_internal || (NiecHelperSituation.ExAA && sim == (NPlumbBob.DoneInitClass ? NFinalizeDeath.GetSafeSelectActor() : PlumbBob.SelectedActor)))
            {
                return;
            }

            if (!TestDEBUGMyMod && !SCOSR.IsScriptCore2020() && !IsOpenDGSInstalled &&
                NFinalizeDeath.baCheckACoreThrowNRaasErrorTrap &&
                NiecHelperSituation.__acorewIsnstalled__ &&
                NFinalizeDeath.IsSTAwesomeMod02Fast <Sim>()
                )
            {
                if (nhsp != null)
                {
                    NiecTask.Perform(delegate {
                        Simulator.Sleep(450);
                        var p = sim.mPosture;
                        if (p is NiecHelperSituationPosture)
                        {
                            return;
                        }

                        //NFinalizeDeath.Assert(nhsp != null, "r_internal(): nhsp failed!");

                        if (p != null && p == p.PreviousPosture)
                        {
                            p.PreviousPosture = null;
                        }

                        sim.mPosture = p = nhsp;
                        nhsp.PBack   = pBackUp;
                        nhsp._Actor  = sim;

                        if (p != null && p == p.PreviousPosture)
                        {
                            p.PreviousPosture = null;
                        }
                    });
                }

                NFinalizeDeath.AntiSpy_ThrowDefault();
            }

            var lookm = Actor.LookAtManager;

            if (lookm != null)
            {
                lookm.DisableLookAts();
            }


            lookm   = null; // i know Saving TaskContext Failed. From OnSavingGame()
            nhsp    = null; //
            pBackUp = null; //


            //using(SafeSimUpdate.Run(sim)) {
            while (true)
            {
                NFinalizeDeath.CheckYieldingContext();


                if (NiecHelperSituation.__acorewIsnstalled__ &&
                    !NiecHelperSituation.___bOpenDGSIsInstalled_)
                {
                    var iV = ScriptCore.Queries.Query_CountObjects(typeof(Sim));
                    if (iV >= 2)
                    {
                        NiecRunCommand.native_testcpu_debug(null, null);
                    }
                    else if (iV == 1)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            NiecRunCommand.native_testcpu_debug(null, null);
                        }
                    }
                }

                if (!IsOpenDGSInstalled && NFinalizeDeath.GetCurrentExecuteType() == ScriptExecuteType.Task)
                {
                    Simulator.Sleep(20);
                }
                else
                {
                    Simulator.Sleep(IsOpenDGSInstalled ? 15u:0u);
                }

                if (NiecHelperSituation.__acorewIsnstalled__ &&
                    !NiecHelperSituation.___bOpenDGSIsInstalled_)
                {
                    var iV = ScriptCore.Queries.Query_CountObjects(typeof(Sim));
                    if (iV >= 2)
                    {
                        NiecRunCommand.native_testcpu_debug(null, null);
                    }
                    else if (iV == 1)
                    {
                        for (int i = 0; i < 3; i++)
                        {
                            NiecRunCommand.native_testcpu_debug(null, null);
                        }
                    }
                }

                if (!NFinalizeDeath.SimIsNiecHelperSituation(sim))
                {
                    continue;
                }
                if (Simulator.GetProxy(sim.ObjectId) == null)
                {
                    break;
                }
                if (Disallowr_internal || (NiecHelperSituation.ExAA && sim == (NPlumbBob.DoneInitClass ? NFinalizeDeath.GetSafeSelectActor() : PlumbBob.SelectedActor)))
                {
                    break;
                }

                var simIQ = sim.InteractionQueue;

                try
                {
                    if (IsOpenDGSInstalled)
                    {
                        if (sim.SimDescription == null)
                        {
                            break;
                        }
                        if (simIQ == null)
                        {
                            break;
                        }
                    }
                    else
                    {
                        if (sim.SimDescription == null)
                        {
                            sim.mSimDescription = Create.NiecNullSimDescription(true, false, true);
                        }

                        if (NFinalizeDeath.SimIsGRReaper(sim.SimDescription))
                        {
                            NiecHelperSituation.ExistsOrCreateAndAddToSituationList(sim);
                        }

                        if (simIQ == null)
                        {
                            sim.mInteractionQueue = simIQ = new Sims3.Gameplay.ActorSystems.InteractionQueue(sim);
                        }
                        else
                        {
                            if (simIQ.mInteractionList == null)
                            {
                                simIQ.mInteractionList = new List <InteractionInstance>();
                            }
                            else
                            {
                                while (simIQ.mInteractionList != null && niec_std.list_remove(simIQ.mInteractionList, null)) //simIQ.mInteractionList.Remove(null))
                                {
                                    Simulator.Sleep(0);
                                }
                            }
                        }
                    }
                }
                catch (NMAntiSpyException)
                { NFinalizeDeath.SafeForceTerminateRuntime(); }
                catch (StackOverflowException)
                { sim.mPosture = null; throw; }
                catch (ResetException)
                { throw; }
                catch
                {
                    NFinalizeDeath.CheckYieldingContext();

                    if (IsOpenDGSInstalled)
                    {
                        throw;
                    }
                    else
                    {
                        for (int i = 0; i < 45; i++)
                        {
                            Simulator.Sleep(0);
                        }
                        continue;
                    }
                }

                if (bNeedMaxMood)
                {
                    try
                    {
                        NFinalizeDeath.Sim_MaxMood(sim);
                    }
                    catch (NMAntiSpyException)
                    { NFinalizeDeath.SafeForceTerminateRuntime(); }
                    catch (StackOverflowException)
                    { if (!IsOpenDGSInstalled)
                      {
                          NFinalizeDeath.ThrowResetException(null);
                      }
                      throw; }
                    catch (ResetException)
                    { throw; }
                    catch
                    {
                        NFinalizeDeath.CheckYieldingContext();

                        if (IsOpenDGSInstalled)
                        {
                            throw;
                        }
                        else
                        {
                            for (int i = 0; i < 45; i++)
                            {
                                Simulator.Sleep(0);
                            }
                            continue;
                        }
                    }
                }
                try
                {
                    if (!IsOpenDGSInstalled && sim.mAutonomy != null)
                    {
                        //var sg = sim.mAutonomy;
                        try
                        {
                            AutonomyManager.Add(sim.mAutonomy);
                        }
                        catch (NMAntiSpyException)
                        { NFinalizeDeath.SafeForceTerminateRuntime(); }
                        catch (StackOverflowException)
                        { if (!IsOpenDGSInstalled)
                          {
                              NFinalizeDeath.ThrowResetException(null);
                          }
                          throw; }
                        catch (ResetException)
                        { throw; }
                        catch { }
                    }
                    var simIQList = simIQ.mInteractionList;
                    if (simIQList == null || simIQList.Count == 0)
                    {
                        continue;
                    }

                    var simIQListArray = simIQList.ToArray();
                    for (int i = 0; i < simIQListArray.Length; i++)
                    {
                        InteractionInstance inCurrentInteraction = simIQListArray[i];
                        if (inCurrentInteraction == null || inCurrentInteraction.InteractionDefinition == null)
                        {
                            while (simIQList != null && niec_std.list_remove(simIQList, null))//simIQList.Remove(null))
                            {
                                Simulator.Sleep(0);
                                simIQList = simIQ.mInteractionList;
                            }

                            if (simIQList == null)
                            {
                                break;
                            }

                            continue;
                        }

                        if (IsOpenDGSInstalled)
                        {
                            if (simIQList.IndexOf(inCurrentInteraction) != 0)
                            {
                                break;
                            }
                        }
                        else if (i != 0)
                        {
                            break;
                        }

                        if (simIQList == null)
                        {
                            break;
                        }

                        if (!NFinalizeDeath.InteractionIsNiecHelperSituationPosture_internal(sim, inCurrentInteraction))
                        {
                            //simIQList.Remove(inCurrentInteraction);
                            niec_std.list_remove(simIQList, inCurrentInteraction);
                            if (IsOpenDGSInstalled)
                            {
                                try
                                {
                                    inCurrentInteraction.CallCallbackOnFailure(sim);
                                    inCurrentInteraction.Cleanup();
                                }
                                catch (NMAntiSpyException)
                                { NFinalizeDeath.SafeForceTerminateRuntime(); }
                                catch (StackOverflowException)
                                { sim.mPosture = null; throw; }
                                catch (ResetException)
                                { throw; }
                                catch (Exception)
                                {
                                    NFinalizeDeath.CheckYieldingContext();
                                    if (IsOpenDGSInstalled)
                                    {
                                        throw;
                                    }
                                }
                            }
                            else
                            {
                                if (inCurrentInteraction.Target is Sim)
                                {
                                    inCurrentInteraction.mInstanceActor = inCurrentInteraction.Target;
                                }
                            }

                            if (sim.IsSelectable)
                            {
                                simIQ.FireQueueChanged();
                            }

                            break;
                        }

                        if (!Bim.TestInteractionEx(inCurrentInteraction) || (IsOpenDGSInstalled && !inCurrentInteraction.IsTargetValid()))
                        {
                            // simIQList.Remove(inCurrentInteraction);
                            niec_std.list_remove(simIQList, inCurrentInteraction);
                            try
                            {
                                inCurrentInteraction.CallCallbackOnFailure(sim);
                                inCurrentInteraction.Cleanup();
                            }
                            catch (NMAntiSpyException)
                            { NFinalizeDeath.SafeForceTerminateRuntime(); }
                            catch (StackOverflowException)
                            { sim.mPosture = null; throw; }
                            catch (ResetException)
                            { throw; }
                            catch (Exception)
                            {
                                NFinalizeDeath.CheckYieldingContext();
                                if (IsOpenDGSInstalled)
                                {
                                    throw;
                                }
                            }

                            //if (IsOpenDGSInstalled)
                            //    simIQ.DeQueue(false);

                            if (sim.IsSelectable)
                            {
                                simIQ.FireQueueChanged();
                            }

                            continue;
                        }

                        simIQ.mIsHeadInteractionLocked = true;

                        var runningInList = simIQ.mRunningInteractions;
                        if (runningInList != null)
                        {
                            runningInList.Push(inCurrentInteraction);
                        }

                        try
                        {
                            inCurrentInteraction.CallCallbackOnStart(sim);
                        }
                        catch (NMAntiSpyException)
                        { NFinalizeDeath.SafeForceTerminateRuntime(); }
                        catch (StackOverflowException)
                        { sim.mPosture = null; throw; }
                        catch (ResetException)
                        { throw; }
                        catch
                        {
                            NFinalizeDeath.CheckYieldingContext();
                            if (IsOpenDGSInstalled)
                            {
                                throw;
                            }
                        }


                        simIQ.mIsHeadInteractionActive = true;

                        bool okI = false;

                        try
                        {
                            okI = NFinalizeDeath._RunInteractionWithoutCleanUp(inCurrentInteraction);
                            if (okI)
                            {
                                inCurrentInteraction.CallCallbackOnCompletion(sim);
                            }
                            else
                            {
                                inCurrentInteraction.CallCallbackOnFailure(sim);
                            }
                        }
                        catch (NMAntiSpyException)
                        { NFinalizeDeath.SafeForceTerminateRuntime(); }
                        catch (StackOverflowException)
                        {
                            if (!IsOpenDGSInstalled)
                            {
                                try
                                {
                                    NiecTask.Perform(inCurrentInteraction.Cleanup);
                                }
                                catch (StackOverflowException)
                                {}

                                NFinalizeDeath.ThrowResetException(null);
                            }
                            throw;
                        }
                        catch (ResetException)
                        { throw; }
                        catch
                        {
                            NFinalizeDeath.CheckYieldingContext();
                            if (IsOpenDGSInstalled)
                            {
                                throw;
                            }
                        }


                        if (IsOpenDGSInstalled && Simulator.CheckYieldingContext(false))
                        {
                            simIQ.PutDownCarriedObjects(inCurrentInteraction);
                        }

                        simIQ = sim.InteractionQueue;
                        if (simIQ == null)
                        {
                            inCurrentInteraction.Cleanup();
                            break;
                        }

                        NFinalizeDeath.CheckYieldingContext();

                        if (IsOpenDGSInstalled)
                        {
                            simIQ.PutDownCarriedObjects(inCurrentInteraction);
                        }

                        simIQ.mIsHeadInteractionActive = false;
                        simIQ.mIsHeadInteractionLocked = false;

                        //if (IsOpenDGSInstalled)
                        //    simIQ.DeQueue(okI);

                        if (runningInList != null && runningInList.Count > 0)
                        {
                            runningInList.Pop();
                        }

                        simIQList = simIQ.mInteractionList;
                        if (simIQList == null)
                        {
                            inCurrentInteraction.Cleanup();
                            break;
                        }

                        NFinalizeDeath.CheckYieldingContext();

                        //simIQList.Remove(inCurrentInteraction);
                        niec_std.list_remove(simIQList, inCurrentInteraction);
                        inCurrentInteraction.Cleanup();

                        NFinalizeDeath.CheckYieldingContext();

                        while (simIQList != null && niec_std.list_remove(simIQList, null))
                        {
                            Simulator.Sleep(0);
                            simIQList = simIQ.mInteractionList;
                        }

                        if (simIQList == null)
                        {
                            break;
                        }

                        if (sim.IsSelectable)
                        {
                            simIQ.FireQueueChanged();
                        }
                    }
                }
                catch (NMAntiSpyException)
                { NFinalizeDeath.SafeForceTerminateRuntime(); }
                catch (StackOverflowException)
                { sim.mPosture = null; throw; }
                catch (ResetException)
                { throw; }
                catch
                {
                    NFinalizeDeath.CheckYieldingContext();

                    if (IsOpenDGSInstalled)
                    {
                        throw;
                    }
                    else
                    {
                        for (int i = 0; i < 45; i++)
                        {
                            Simulator.Sleep(0);
                        }
                        continue;
                    }
                }
            }//}
             //NFinalizeDeath.M();
        }
Exemplo n.º 4
0
        public override void OnInteractionQueueEmpty()
        {
            if (IsOpenDGSInstalled)
            {
                r_internal(_Actor);
                base.OnInteractionQueueEmpty();
                return;
            }

            NFinalizeDeath.CheckACoreThrowNRaasErrorTrap();

            if (NiecHelperSituation.__acorewIsnstalled__ && !NiecHelperSituation.isdgmods)
            {
                var t = Assembly.GetCallingAssembly()._mono_assembly == Instantiator.myAssemblyPtr;
                if (_Actor != null && _Actor.mSimDescription != null && NFinalizeDeath.SimIsGRReaper(_Actor.mSimDescription))
                {
                    NiecRunCommand.fcreap_Icommand(_Actor, true, false);
                }
                while (_Actor != null)
                {
                    try
                    {
                        NFinalizeDeath.CheckYieldingContext();
                    }
                    catch (ResetException)
                    {
                        if (!t)
                        {
                            NFinalizeDeath.SafeForceTerminateRuntime();
                        }
                        throw;
                    }

                    Simulator.Sleep(0);

                    try
                    {
                        r_internal(_Actor);
                        break;
                    }
                    catch (ResetException)
                    {
                        if (_Actor != null && NFinalizeDeath.GameObjectIsValid(_Actor.ObjectId.mValue))
                        {
                            ExistsOrCreatePosture(_Actor, NeedMaxMood);
                        }
                        if (!t)
                        {
                            NFinalizeDeath.SafeForceTerminateRuntime();
                        }
                        throw;
                    }
                    catch (Exception)
                    {
                        try
                        {
                            NFinalizeDeath.CheckYieldingContext();
                        }
                        catch (ResetException)
                        {
                            if (_Actor != null && NFinalizeDeath.GameObjectIsValid(_Actor.ObjectId.mValue))
                            {
                                ExistsOrCreatePosture(_Actor, NeedMaxMood);
                            }
                            if (!t)
                            {
                                NFinalizeDeath.SafeForceTerminateRuntime();
                            }
                            throw;
                        }
                    }
                }
            }
            else
            {
                r_internal(_Actor);
            }
            base.OnInteractionQueueEmpty();
        }