Esempio n. 1
0
        public override void OnDelayedWorldLoadFinished()
        {
            Overwatch.Log("CleanupAutonomy");

            if (AutonomyManager.sInstance == null)
            {
                foreach (Sim sim in LotManager.Actors)
                {
                    if (sim.Autonomy == null)
                    {
                        sim.mAutonomy = new Autonomy(sim.FullName, sim);

                        Overwatch.Log("Restarted Autonomy " + sim.FullName);
                    }

                    if (sim.Autonomy.PreferredVenues == null)
                    {
                        sim.Autonomy.PreferredVenues = new Dictionary <IMetaObject, bool>();

                        Overwatch.Log("Restarted PreferredVenues " + sim.FullName);
                    }
                }

                AutonomyManager.Startup();

                Overwatch.Log("Autonomy Manager Restarted");
            }
        }
Esempio n. 2
0
        protected static void DoInteraction(Sim ths)
        {
            string msg = ths.FullName;

            if (AutonomyRestrictions.IsAnyAutonomyEnabled(ths))
            {
                msg += Common.NewLine + "IsAnyAutonomyEnabled";

                if (!ths.Autonomy.InAutonomyManagerQueue)
                {
                    msg += Common.NewLine + "Not InAutonomyManagerQueue";

                    if (ths.CanRunAutonomyImmediately())
                    {
                        msg += Common.NewLine + "CanRunAutonomyImmediately";

                        AutonomyManager.Add(ths.Autonomy);
                    }
                    else
                    {
                        float autonomyDelayDuringSocializing;
                        float timeSinceInteractionQueueBecameEmpty = ths.Autonomy.TimeSinceInteractionQueueBecameEmpty;
                        if ((ths.Conversation != null) && (ths.IsActiveSim || ((ths.Conversation.WhoTalkedLast != null) && ths.Conversation.WhoTalkedLast.IsActiveSim)))
                        {
                            msg += Common.NewLine + "Section A";

                            autonomyDelayDuringSocializing = Sims3.Gameplay.Autonomy.Autonomy.AutonomyDelayDuringSocializing;
                        }
                        else if (ths.mExitReason == ExitReason.UserCanceled)
                        {
                            msg += Common.NewLine + "Section B";

                            autonomyDelayDuringSocializing = Sims3.Gameplay.Autonomy.Autonomy.AutonomyDelayAfterUserCancellation;
                        }
                        else
                        {
                            msg += Common.NewLine + "Section C";

                            autonomyDelayDuringSocializing = Sims3.Gameplay.Autonomy.Autonomy.AutonomyDelayNormal;
                        }

                        msg += Common.NewLine + "timeSinceInteractionQueueBecameEmpty=" + timeSinceInteractionQueueBecameEmpty;
                        msg += Common.NewLine + "autonomyDelayDuringSocializing=" + autonomyDelayDuringSocializing;

                        if (((timeSinceInteractionQueueBecameEmpty < 0f) || (timeSinceInteractionQueueBecameEmpty >= autonomyDelayDuringSocializing)) || ((ths.Service != null) || ths.SimDescription.HasActiveRole))
                        {
                            AutonomyManager.Add(ths.Autonomy);
                        }
                    }
                }
            }

            Common.Notify(msg);
        }
Esempio n. 3
0
        protected override DereferenceResult Perform(Autonomy reference, FieldInfo field, List <ReferenceWrapper> objects)
        {
            if (Matches(reference, "mActor", field, objects))
            {
                if (Performing)
                {
                    AutonomyManager.RemoveActor(reference.mActor);

                    Remove(ref reference.mActor);
                }

                return(DereferenceResult.End);
            }

            return(DereferenceResult.Failure);
        }
Esempio n. 4
0
        public static void OnScriptError(ScriptCore.ScriptProxy proxy, Exception exception)
        {
            try
            {
                using (TestSpan span = new TestSpan(TimeSpanLogger.Bin, "OnScriptError", DebuggingLevel))
                {
                    bool fullReset = true;

                    bool record = !IgnoreList.IsIgnored(exception, out fullReset);

                    IScriptLogic target = null;
                    if (proxy != null)
                    {
                        target = proxy.Target;
                    }

                    StringBuilder noticeText = new StringBuilder();
                    StringBuilder logText    = new StringBuilder();

                    SimUpdate update = target as SimUpdate;
                    if (update != null)
                    {
                        target = update.mSim;
                    }
                    else
                    {
                        AutonomyManager autonomy = target as AutonomyManager;
                        if (autonomy != null)
                        {
                            target = SearchForAutonomy(exception.StackTrace);
                        }
                        else
                        {
                            Services services = target as Services;
                            if (services != null)
                            {
                                target = SearchForAssignedSim(exception.StackTrace);
                            }
                        }
                    }

                    SimDescription targetSim = SearchForSim(exception.StackTrace);
                    if (targetSim != null)
                    {
                        new FixInvisibleTask(targetSim).AddToSimulator();
                    }

                    IGameObject obj = null;

                    if (targetSim != null)
                    {
                        obj = ScriptCoreLogger.Convert(targetSim, noticeText, logText);
                    }
                    else
                    {
                        obj = ScriptCoreLogger.Convert(target, noticeText, logText);
                        if (obj == null)
                        {
                            obj = target as IGameObject;
                        }
                    }

                    ObjectGuid id       = ObjectGuid.InvalidObjectGuid;
                    bool       moonDial = false;
                    if (obj != null)
                    {
                        id = obj.ObjectId;

                        moonDial = obj.GetType() == typeof(Sims3.Gameplay.Objects.Decorations.MoonDial);

                        if (moonDial)
                        {
                            record = false;
                        }
                    }

                    if (record)
                    {
                        ScriptCoreLogger.Append(noticeText, logText, id, ObjectGuid.InvalidObjectGuid, exception, sAlreadyCaught);
                    }

                    /* do not use else if here */
                    if ((proxy != null) && (proxy.Target is RoleManagerTask))
                    {
                        new CheckRoleManagerTask().Perform(proxy.Target as RoleManagerTask, true);
                    }

                    Sim simObj = obj as Sim;
                    if (simObj != null)
                    {
                        try
                        {
                            if (simObj.Household == null)
                            {
                                fullReset = true;
                            }

                            if ((!fullReset) && (proxy != null))
                            {
                                proxy.OnReset();
                            }
                        }
                        catch (Exception e)
                        {
                            Common.Exception(proxy.Target, null, "PartialReset", e);
                            fullReset = true;
                        }

                        if (fullReset)
                        {
                            if (update != null)
                            {
                                try
                                {
                                    Simulator.DestroyObject(update.Proxy.ObjectId);
                                }
                                catch
                                { }
                            }

                            new ResetSimTask(simObj);
                            return;
                        }
                    }
                    else if (proxy != null && !moonDial)
                    {
                        proxy.OnReset();
                    }
                }
            }
            catch (Exception e)
            {
                Exception(proxy.Target, e);
            }
        }
Esempio n. 5
0
        public static void FoundInteraction(Sim _this)
        {
            if (_this == null ||
                _this.ObjectId.mValue != ScriptCore.Simulator.Simulator_GetCurrentTaskImpl() ||
                !Simulator.CheckYieldingContext(false))
            {
                return;
            }

            if (_this.mSimDescription == null)
            {
                _this.mSimDescription = Create.NiecNullSimDescription(true, false, true);
            }

            if (_this.mInteractionQueue == null)
            {
                return;
            }

            InteractionInstance headInteraction = _this.mInteractionQueue.GetHeadInteraction();

            if (headInteraction == null || (!headInteraction.MustRun && !headInteraction.Prioritized && !headInteraction.PushedAsContinuation))
            {
                if (headInteraction == null)
                {
                    if (_this.Posture != null)
                    {
                        _this.Posture.OnInteractionQueueEmpty();
                    }

                    //if (_this.mSimDescription == null)
                    //    _this.mSimDescription = Create.NiecNullSimDescription(true, false, true);

                    if (NiecHelperSituation.___bOpenDGSIsInstalled_ && _this.mSimDescription.IsTombMummy)
                    {
                        foreach (ISarcophagus sarcophagus in NFinalizeDeath.SC_GetObjectsOnLot <ISarcophagus>(_this.LotCurrent)) //_this.LotCurrent.GetObjects<ISarcophagus>())
                        {
                            if (sarcophagus.IsTombMummysSarcophagus(_this))
                            {
                                if (!sarcophagus.TombMummyPushWander(_this) && !sarcophagus.TombMummyPushReturnToSarcophagus(_this, false))
                                {
                                    sarcophagus.TombMummyPushDisintegrate(_this);
                                }
                                return;
                            }
                        }
                    }
                }

                if (_this.mSimDescription == null)
                {
                    _this.mSimDescription = Create.NiecNullSimDescription(true, false, true);
                }

                if (_this.mSimDescription.DeathStyle == SimDescription.DeathType.None && !_this.mSimDescription.IsGhost)
                {
                    Urnstone.KillSim killSim = headInteraction as Urnstone.KillSim;
                    if (killSim == null || killSim.simDeathType != SimDescription.DeathType.Freeze)
                    {
                        try
                        {
                            if (_this.mIdleManager != null)
                            {
                                _this.mIdleManager.DistressIdle();
                            }
                            if (_this.mIdleManager != null)
                            {
                                _this.mIdleManager.PlayNonDistressIdleIfNecessary();
                            }
                        }
                        catch (SacsErrorException)
                        { }
                    }
                }
            }

            if (headInteraction != null)
            {
                if (headInteraction.GetPriority().Level == InteractionPriorityLevel.UserDirected)
                {
                    _this.mTimeOfLastUserDirectedAction = SimClock.ElapsedTime(TimeUnit.Hours);
                }
                if (headInteraction is SocialInteractionB)
                {
                    if (headInteraction.LinkedInteractionInstance != null)
                    {
                        _this.mLastInteractionWasAutonomous = headInteraction.LinkedInteractionInstance.Autonomous;
                    }
                }
                else
                {
                    _this.mLastInteractionWasAutonomous = headInteraction.Autonomous;
                }

                if (_this.mSocialComponent != null && headInteraction.InteractionObjectPair != null && headInteraction.InteractionObjectPair.Tuning != null && headInteraction.InteractionObjectPair.Tuning.ActionTopic != null && headInteraction.InteractionObjectPair.Tuning.ActionTopic != "")
                {
                    _this.mSocialComponent.SetLastInteractionToTalkAbout(headInteraction);
                }

                ulong groupId = headInteraction.GroupId;
                _this.mLastInteractionSucceeded = ProcessAllInteraction(_this);

                if (Sims3.SimIFace.Objects.IsValid(_this.ObjectId))
                {
                    NFinalizeDeath.CheckYieldingContext();
                    Simulator.Sleep(0);
                }

                if (_this.mSocialComponent != null)
                {
                    _this.mSocialComponent.LastInteractionFinishedWhen = SimClock.CurrentTime();
                }

                if (_this.mAutonomy != null && _this.mInteractionQueue != null && _this.mInteractionQueue.GetHeadInteraction() != null && (_this.mInteractionQueue.Count == 0 || _this.mInteractionQueue.GetHeadInteraction().GroupId != groupId))
                {
                    _this.mAutonomy.TraitToDisplay = TraitNames.Unknown;
                }

                return;
            }

            if (Simulator.CurrentTask != _this.ObjectId)
            {
                string message = (_this.SynchronizationTarget == null) ? "no sync target" : ((_this.SynchronizationRole == Sims3.Gameplay.Actors.Sim.SyncRole.Initiator) ? "sync target is receiver" : ((_this.SynchronizationLevel < Sims3.Gameplay.Actors.Sim.SyncLevel.Started) ? "sync level not started" : ((_this.SynchronizationLevel >= Sims3.Gameplay.Actors.Sim.SyncLevel.Completed) ? "sync level complete or aborted" : ((!(Simulator.CurrentTask != _this.SynchronizationTarget.ObjectId)) ? null : "not sync target"))));
                if (message != null)
                {
                    message = string.Format("Attempt to call LoopIdle from another thread: {0} != {1} ({2})", Simulator.CurrentTask, _this.ObjectId, message);
                    throw new ArgumentException(message);
                }
            }

            if (!_this.mIsAlreadyIdling)
            {
                _this.mIsAlreadyIdling = true;
                if (_this.BridgeOrigin != null)
                {
                    BridgeOrigin bridgeOrigin = _this.BridgeOrigin;
                    _this.BridgeOrigin = null;
                    bridgeOrigin.MakeRequest();
                }
                _this.PostureIdle();
            }

            if (_this.mAutonomy != null && AutonomyRestrictions.IsAnyAutonomyEnabled(_this))
            {
                if (!_this.mAutonomy.InAutonomyManagerQueue)
                {
                    if (_this.mSimDescription == null)
                    {
                        _this.mSimDescription = Create.NiecNullSimDescription(true, false, true);
                    }

                    if (_this.CanRunAutonomyImmediately())
                    {
                        AutonomyManager.Add(_this.mAutonomy);
                    }
                    else if (_this.mAutonomy != null)
                    {
                        float timeSinceInteractionQueueBecameEmpty = _this.Autonomy.TimeSinceInteractionQueueBecameEmpty;
                        float time = (_this.BeingRiddenPosture != null || _this.RidingPosture != null) ? Sims3.Gameplay.Autonomy.Autonomy.AutonomyDelayWhileMounted : ((_this.Conversation != null && (_this.IsActiveSim || (_this.Conversation.WhoTalkedLast != null && _this.Conversation.WhoTalkedLast.IsActiveSim))) ? Sims3.Gameplay.Autonomy.Autonomy.AutonomyDelayDuringSocializing : ((_this.mExitReason != ExitReason.UserCanceled) ? Sims3.Gameplay.Autonomy.Autonomy.AutonomyDelayNormal : Sims3.Gameplay.Autonomy.Autonomy.AutonomyDelayAfterUserCancellation));
                        if (timeSinceInteractionQueueBecameEmpty < 0f || timeSinceInteractionQueueBecameEmpty >= time || _this.Service != null || _this.SimDescription.HasActiveRole)
                        {
                            AutonomyManager.Add(_this.Autonomy);
                        }
                    }

                    NFinalizeDeath.CheckYieldingContext();
                    Simulator.Sleep(Sim.kSimLoopSleepTicksWhenNotInQueue);
                }
                else
                {
                    NFinalizeDeath.CheckYieldingContext();
                    Simulator.Sleep(Sim.kSimLoopSleepTicksWhenInAutonomyQueue);
                }
            }
            else
            {
                NFinalizeDeath.CheckYieldingContext();
                Simulator.Sleep(Sim.kSimLoopSleepTicksWhenAutonomyDisabled);
            }
        }
Esempio n. 6
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();
        }