Exemplo n.º 1
0
        protected static void OnTimer()
        {
            try
            {
                foreach (Sim sim in LotManager.Actors)
                {
                    try
                    {
                        DreamsAndPromisesManager dnp = sim.DreamsAndPromisesManager;
                        if (dnp == null)
                        {
                            continue;
                        }

                        if ((!sim.IsSelectable) && (dnp.NeedsUpdate))
                        {
                            dnp.SetToUpdate(true, false);
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnTimer", e);
            }
        }
Exemplo n.º 2
0
        public static void ParseEWCatFishingPrimitives()
        {
            //sNodePrimitves = new Dictionary<uint, DreamNodePrimitive>();

            List <DreamNodePrimitive> cachePrimitives = new List <DreamNodePrimitive>();
            XmlDbData xmlDbData = XmlDbData.ReadData(new ResourceKey(0xC54CBCBB14C4EC27, 0x0333406C, 0x00000000), false);

            if (xmlDbData != null)
            {
                DreamsAndPromisesManager.ParseNodePrimitivesFromXmlDbData(xmlDbData, ref cachePrimitives, isStore: false);
            }
        }
Exemplo n.º 3
0
        public static void PruneDreamManager(Sim sim)
        {
            if (sim == null)
            {
                return;
            }

            DreamsAndPromisesManager dnp = sim.DreamsAndPromisesManager;

            if (dnp == null)
            {
                return;
            }

            List <ActiveNodeBase> activeNodes = dnp.mActiveNodes;

            if (activeNodes != null)
            {
                for (int i = activeNodes.Count - 1; i >= 0; i--)
                {
                    try
                    {
                        activeNodes[i].CreateExportFromNode();
                    }
                    catch (Exception e)
                    {
                        activeNodes.RemoveAt(i);

                        Common.DebugException("ActiveNode", e);
                    }
                }
            }

            List <ActiveDreamNode> sleepingNodes = dnp.mSleepingNodes;

            if (sleepingNodes != null)
            {
                for (int i = sleepingNodes.Count - 1; i >= 0; i--)
                {
                    try
                    {
                        sleepingNodes[i].CreateExportFromNode();
                    }
                    catch (Exception e)
                    {
                        sleepingNodes.RemoveAt(i);

                        Common.DebugException("SleepingNode", e);
                    }
                }
            }
        }
Exemplo n.º 4
0
        public static void ParseEWCatFishingDreamTrees()
        {
            Dictionary <string, XmlElement> instanceDefults = DreamsAndPromisesManager.ParseDefaults();
            List <DreamTree> cacheTrees = new List <DreamTree>();

            uint[]      array  = new uint[2];
            uint[]      array2 = array;
            ResourceKey item   = new ResourceKey(0xA43129F3D1D0E08C, 0x0604ABDA, 0x0);

            array2[0]++;
            if (DreamsAndPromisesManager.ParseDreamTreeByKey(item, instanceDefults, ref cacheTrees))
            {
                array2[1]++;
            }
        }
Exemplo n.º 5
0
            protected override List <IGenericValueOption <LifetimeWant> > GetAllOptions()
            {
                List <IGenericValueOption <LifetimeWant> > results = new List <IGenericValueOption <LifetimeWant> >();

                if (Sims3.Gameplay.Actors.Sim.ActiveActor != null)
                {
                    List <IInitialMajorWish> allMajorDreamMatches = DreamsAndPromisesManager.GetAllMajorDreamMatches(Sims3.Gameplay.Actors.Sim.ActiveActor.SimDescription);

                    foreach (IInitialMajorWish ltw in allMajorDreamMatches)
                    {
                        results.Add(new ListItem(this, ltw));
                    }
                }

                return(results);
            }
Exemplo n.º 6
0
            public override void SetValue(uint value, uint storeType)
            {
                mValue = value;

                if (value == 0)
                {
                    mName = Common.Localize("Criteria.LifetimeWish:None");
                }
                else
                {
                    DreamNodeInstance wish = DreamsAndPromisesManager.GetMajorDream(value) as DreamNodeInstance;
                    if (wish != null)
                    {
                        mName = wish.GetMajorWishName(Sim.ActiveActor.SimDescription);
                        SetThumbnail(wish.PrimaryIconKey);
                    }
                }
            }
Exemplo n.º 7
0
        public uint ChooseRandomLifetimeWish(DreamsAndPromisesManager ths)
        {
            List <IInitialMajorWish> topMajorDreamMatches = DreamsAndPromisesManager.GetTopMajorDreamMatches(ths.mActor.SimDescription);

            for (int i = topMajorDreamMatches.Count - 1; i >= 0; i--)
            {
                if (HasValue <DisallowLTWOption, LifetimeWant>((LifetimeWant)topMajorDreamMatches[i].PrimitiveId))
                {
                    topMajorDreamMatches.RemoveAt(i);
                }
            }

            if (topMajorDreamMatches.Count > 0x0)
            {
                return(RandomUtil.GetRandomObjectFromList <IInitialMajorWish>(topMajorDreamMatches).PrimitiveId);
            }

            return(0x0);
        }
Exemplo n.º 8
0
        protected override bool Run(SimDescription me, bool singleSelection)
        {
            if (me.CreatedSim == null)
            {
                return(false);
            }

            if (me.LifetimeWish != 0)
            {
                IInitialMajorWish wish = DreamsAndPromisesManager.GetMajorDream(me.LifetimeWish);
                if (wish != null)
                {
                    if (!AcceptCancelDialog.Show(Common.Localize("ChangeLifetimeWish:Prompt", me.IsFemale, new object[] { me, wish.GetMajorWishName(me) })))
                    {
                        return(false);
                    }
                }
            }

            LifetimeWants.SetLifetimeWant(me);
            return(true);
        }
Exemplo n.º 9
0
        protected static ListenerAction OnEvent(Event paramE)
        {
            try
            {
                if (!EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers)
                {
                    try
                    {
                        EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = true;
                        while (DreamsAndPromisesManager.sNeedToUpdateList.Count > 0)
                        {
                            DreamsAndPromisesManager dnp = DreamsAndPromisesManager.sNeedToUpdateList[0];
                            try
                            {
                                DreamsAndPromisesManagerEx.Update(dnp);
                            }
                            catch (Exception e)
                            {
                                Common.Exception(dnp.Actor, e);
                            }

                            DreamsAndPromisesManager.sNeedToUpdateList.Remove(dnp);
                        }
                    }
                    finally
                    {
                        EventTracker.sCurrentlyUpdatingDreamsAndPromisesManagers = false;
                    }
                }
            }
            catch (Exception e)
            {
                Common.Exception(paramE.Actor, paramE.TargetObject, e);
            }

            return(ListenerAction.Keep);
        }
Exemplo n.º 10
0
        public static bool SetLifetimeWant(SimDescription me)
        {
            List <IInitialMajorWish> topMajorDreamMatches = DreamsAndPromisesManager.GetTopMajorDreamMatches(me);
            List <IInitialMajorWish> allMajorDreamMatches = DreamsAndPromisesManager.GetAllMajorDreamMatches(me);

            if ((topMajorDreamMatches.Count > 0x0) || (allMajorDreamMatches.Count > 0x0))
            {
                uint oldLifetimeWish = me.LifetimeWish;
                uint newLifetimeWish = LifetimeWishSelectionDialog.Show(me, Localization.LocalizeString("Ui/Caption/LifetimeWishSelectionDialog:InitialCaption", new object[0x0]), topMajorDreamMatches, allMajorDreamMatches, true);
                if ((oldLifetimeWish != newLifetimeWish) && (newLifetimeWish != 0x0))
                {
                    me.HasCompletedLifetimeWish = false;
                    me.LifetimeWish             = newLifetimeWish;

                    if (me.CreatedSim.DreamsAndPromisesManager != null)
                    {
                        me.CreatedSim.DreamsAndPromisesManager.TryAddLifetimeWish();
                        return(true);
                    }
                }
            }

            return(false);
        }
Exemplo n.º 11
0
        public static void Update(DreamsAndPromisesManager ths)
        {
            if (!ths.mFullUpdate)
            {
                PartialUpdate(ths);
            }
            else
            {
                ths.mFullUpdate = false;
                float num = SimClock.ElapsedTime(TimeUnit.Minutes);
                float simMinutesPassed = num - ths.mLastUpdateTime;
                ths.mLastUpdateTime = num;
                Dictionary<Event, List<DreamsAndPromisesManager.ScoredNode>> completedNodes = new Dictionary<Event, List<DreamsAndPromisesManager.ScoredNode>>();
                List<ActiveNodeBase> timeoutList = new List<ActiveNodeBase>();
                List<ActiveNodeBase> completedList = new List<ActiveNodeBase>();

                foreach (ActiveNodeBase base2 in new List<ActiveNodeBase>(ths.mActiveNodes))
                {
                    if (DreamerTuning.kNoTimeOut)
                    {
                        ActiveDreamNode node = base2 as ActiveDreamNode;
                        if (node != null)
                        {
                            node.mTimeActive = 0;
                        }
                    }

                    try
                    {
                        switch (base2.Update(simMinutesPassed))
                        {
                            case ActiveNodeBase.UpdateStatus.TimedOut:
                                timeoutList.Add(base2);
                                break;

                            case ActiveNodeBase.UpdateStatus.Completed:
                                {
                                    ActiveDreamNode node = base2 as ActiveDreamNode;
                                    if (((node != null) && (node.CompletionEvent != null)) && !completedNodes.ContainsKey(node.CompletionEvent))
                                    {
                                        completedNodes.Add(node.CompletionEvent, new List<DreamsAndPromisesManager.ScoredNode>());
                                    }
                                    completedList.Add(base2);
                                    break;
                                }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(ths.Actor, e);

                        ths.RemoveActiveNode(base2);
                    }
                }

                ths.RetestVisibleNodes(timeoutList, completedList);
                foreach (ActiveNodeBase base3 in completedList)
                {
                    List<DreamsAndPromisesManager.ScoredNode> list3;
                    if ((base3.PromiseParent != null) && (base3.PromiseParent.WasPromisedAndBroken || base3.PromiseParent.IsComplete))
                    {
                        continue;
                    }
                    ActiveDreamNode node2 = base3 as ActiveDreamNode;
                    if (((node2 == null) || (node2.CompletionEvent == null)) || !completedNodes.TryGetValue(node2.CompletionEvent, out list3))
                    {
                        list3 = new List<DreamsAndPromisesManager.ScoredNode>();
                        completedNodes.Add(new Event(EventTypeId.kEventNone), list3);
                    }
                    if (node2 != null)
                    {
                        ths.RemoveCompletedNode(node2);
                    }

                    try
                    {
                        list3.AddRange(ths.ScoreChildren(base3, completedNodes, false, base3.GetNonPromiseLinkChildren()));
                    }
                    catch(Exception e)
                    {
                        Common.DebugException(ths.Actor, e);
                    }
                }

                bool flag = ths.SelectDreamsToDisplay(completedNodes);
                foreach (ActiveNodeBase base4 in timeoutList)
                {
                    ths.RemoveActiveNode(base4);
                    flag = true;
                }

                List<ActiveDreamNode> list4 = new List<ActiveDreamNode>();
                foreach (ActiveDreamNode node3 in ths.mSleepingNodes)
                {
                    if (node3.UpdateSleeping(simMinutesPassed))
                    {
                        node3.Reset(true);
                        ths.mActiveNodes.Add(node3);
                        ths.AddToReferenceList(node3);
                        list4.Add(node3);
                    }
                }

                foreach (ActiveDreamNode node4 in list4)
                {
                    ths.mSleepingNodes.Remove(node4);
                }

                foreach (ActiveNodeBase base5 in completedList)
                {
                    ActiveDreamNode node5 = base5 as ActiveDreamNode;
                    ActiveTimerNode node6 = base5 as ActiveTimerNode;
                    bool flag2 = true;
                    if (node5 != null)
                    {
                        if (!ActiveDreamNodeEx.OnCompletion(node5))
                        {
                            flag2 = false;
                        }
                        else if ((node5.IsRepeatable) && (ths.IsNotSpecialCaseNode(node5.NodeInstance.PrimitiveId) && ((node5.DebugCompleteFlags & ActiveDreamNode.DebugCompleteReasons.kStartNode) == ActiveDreamNode.DebugCompleteReasons.kNone)))
                        {
                            if (node5.NodeInstance.TimeBetweenRepeats <= 0f)
                            {
                                ths.CancelDream(node5);
                                node5.Reset(true);
                                flag2 = false;
                            }
                            else
                            {
                                node5.Reset(false);
                                ths.mSleepingNodes.Add(node5);
                            }
                        }
                    }
                    if ((node6 != null) && !node6.IsComplete)
                    {
                        flag2 = false;
                    }
                    if (flag2)
                    {
                        ths.RemoveActiveNode(base5);
                    }
                }

                List<ActiveDreamNode> list5 = new List<ActiveDreamNode>();
                foreach (ActiveDreamNode node7 in ths.mDreamNodes)
                {
                    if (node7.TimeActive > node7.NodeInstance.DisplayTime)
                    {
                        list5.Add(node7);
                    }
                }

                foreach (ActiveDreamNode node8 in list5)
                {
                    if ((ths.mDisplayedDreamNodes.Remove(node8) && (ths == DreamsAndPromisesManager.ActiveDreamsAndPromisesManager)) && (DreamsAndPromisesModel.Singleton != null))
                    {
                        DreamsAndPromisesModel.Singleton.FireRemoveDream(node8);
                    }
                    ths.mDreamNodes.Remove(node8);
                }

                if ((flag && (ths == DreamsAndPromisesManager.ActiveDreamsAndPromisesManager)) && (DreamsAndPromisesModel.Singleton != null))
                {
                    ths.RefreshDisplayedDreams();
                }

                if (ths.mShouldRefreshOnUpdate)
                {
                    ths.mShouldRefreshOnUpdate = false;

                    try
                    {
                        ths.Refresh();
                    }
                    catch (Exception e)
                    {
                        Common.Exception(ths.Actor, e);
                    }
                }
            }
        }
Exemplo n.º 12
0
        public static void PartialUpdate(DreamsAndPromisesManager ths)
        {
            List <ActiveDreamNode> activeNodes = new List <ActiveDreamNode>(ths.mCompletedNodes);

            Dictionary <Event, List <DreamsAndPromisesManager.ScoredNode> > completedNodes = new Dictionary <Event, List <DreamsAndPromisesManager.ScoredNode> >();

            foreach (ActiveDreamNode node in activeNodes)
            {
                if ((node.CompletionEvent != null) && !completedNodes.ContainsKey(node.CompletionEvent))
                {
                    completedNodes.Add(node.CompletionEvent, new List <DreamsAndPromisesManager.ScoredNode>());
                }
            }

            foreach (ActiveDreamNode node2 in activeNodes)
            {
                List <DreamsAndPromisesManager.ScoredNode> list;
                if ((node2.PromiseParent != null) && (node2.PromiseParent.WasPromisedAndBroken || node2.PromiseParent.IsComplete))
                {
                    continue;
                }

                if ((node2.CompletionEvent == null) || !completedNodes.TryGetValue(node2.CompletionEvent, out list))
                {
                    list = new List <DreamsAndPromisesManager.ScoredNode>();
                    completedNodes.Add(new Event(EventTypeId.kEventNone), list);
                }

                try
                {
                    list.AddRange(ths.ScoreChildren(node2, completedNodes, false, node2.GetNonPromiseLinkChildren()));
                }
                catch (Exception e)
                {
                    Common.DebugException(ths.Actor, e);
                }
            }

            bool flag = ths.SelectDreamsToDisplay(completedNodes);

            foreach (ActiveDreamNode node3 in activeNodes)
            {
                bool flag2 = true;
                if (!ActiveDreamNodeEx.OnCompletion(node3))
                {
                    flag2 = false;
                }
                else if ((node3.IsRepeatable) && (ths.IsNotSpecialCaseNode(node3.NodeInstance.PrimitiveId) && ((node3.DebugCompleteFlags & ActiveDreamNode.DebugCompleteReasons.kStartNode) == ActiveDreamNode.DebugCompleteReasons.kNone)))
                {
                    if (node3.NodeInstance.TimeBetweenRepeats <= 0f)
                    {
                        ths.CancelDream(node3);
                        node3.Reset(true);
                        flag2 = false;
                    }
                    else
                    {
                        node3.Reset(false);
                        ths.mSleepingNodes.Add(node3);
                    }
                }
                if (flag2)
                {
                    ths.RemoveActiveNode(node3);
                }
            }

            if ((flag && (ths == DreamsAndPromisesManager.ActiveDreamsAndPromisesManager)) && (DreamsAndPromisesModel.Singleton != null))
            {
                ths.RefreshDisplayedDreams();
            }

            if (ths.mShouldRefreshOnUpdate)
            {
                ths.mShouldRefreshOnUpdate = false;

                try
                {
                    ths.Refresh();
                }
                catch (Exception e)
                {
                    Common.Exception(ths.Actor, e);
                }
            }
            ths.mCompletedNodes.Clear();
        }
Exemplo n.º 13
0
        public static void Update(DreamsAndPromisesManager ths)
        {
            if (!ths.mFullUpdate)
            {
                PartialUpdate(ths);
            }
            else
            {
                ths.mFullUpdate = false;
                float num = SimClock.ElapsedTime(TimeUnit.Minutes);
                float simMinutesPassed = num - ths.mLastUpdateTime;
                ths.mLastUpdateTime = num;
                Dictionary <Event, List <DreamsAndPromisesManager.ScoredNode> > completedNodes = new Dictionary <Event, List <DreamsAndPromisesManager.ScoredNode> >();
                List <ActiveNodeBase> timeoutList   = new List <ActiveNodeBase>();
                List <ActiveNodeBase> completedList = new List <ActiveNodeBase>();

                foreach (ActiveNodeBase base2 in new List <ActiveNodeBase>(ths.mActiveNodes))
                {
                    if (DreamerTuning.kNoTimeOut)
                    {
                        ActiveDreamNode node = base2 as ActiveDreamNode;
                        if (node != null)
                        {
                            node.mTimeActive = 0;
                        }
                    }

                    try
                    {
                        switch (base2.Update(simMinutesPassed))
                        {
                        case ActiveNodeBase.UpdateStatus.TimedOut:
                            timeoutList.Add(base2);
                            break;

                        case ActiveNodeBase.UpdateStatus.Completed:
                        {
                            ActiveDreamNode node = base2 as ActiveDreamNode;
                            if (((node != null) && (node.CompletionEvent != null)) && !completedNodes.ContainsKey(node.CompletionEvent))
                            {
                                completedNodes.Add(node.CompletionEvent, new List <DreamsAndPromisesManager.ScoredNode>());
                            }
                            completedList.Add(base2);
                            break;
                        }
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(ths.Actor, e);

                        ths.RemoveActiveNode(base2);
                    }
                }

                ths.RetestVisibleNodes(timeoutList, completedList);
                foreach (ActiveNodeBase base3 in completedList)
                {
                    List <DreamsAndPromisesManager.ScoredNode> list3;
                    if ((base3.PromiseParent != null) && (base3.PromiseParent.WasPromisedAndBroken || base3.PromiseParent.IsComplete))
                    {
                        continue;
                    }
                    ActiveDreamNode node2 = base3 as ActiveDreamNode;
                    if (((node2 == null) || (node2.CompletionEvent == null)) || !completedNodes.TryGetValue(node2.CompletionEvent, out list3))
                    {
                        list3 = new List <DreamsAndPromisesManager.ScoredNode>();
                        completedNodes.Add(new Event(EventTypeId.kEventNone), list3);
                    }
                    if (node2 != null)
                    {
                        ths.RemoveCompletedNode(node2);
                    }

                    try
                    {
                        list3.AddRange(ths.ScoreChildren(base3, completedNodes, false, base3.GetNonPromiseLinkChildren()));
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(ths.Actor, e);
                    }
                }

                bool flag = ths.SelectDreamsToDisplay(completedNodes);
                foreach (ActiveNodeBase base4 in timeoutList)
                {
                    ths.RemoveActiveNode(base4);
                    flag = true;
                }

                List <ActiveDreamNode> list4 = new List <ActiveDreamNode>();
                foreach (ActiveDreamNode node3 in ths.mSleepingNodes)
                {
                    if (node3.UpdateSleeping(simMinutesPassed))
                    {
                        node3.Reset(true);
                        ths.mActiveNodes.Add(node3);
                        ths.AddToReferenceList(node3);
                        list4.Add(node3);
                    }
                }

                foreach (ActiveDreamNode node4 in list4)
                {
                    ths.mSleepingNodes.Remove(node4);
                }

                foreach (ActiveNodeBase base5 in completedList)
                {
                    ActiveDreamNode node5 = base5 as ActiveDreamNode;
                    ActiveTimerNode node6 = base5 as ActiveTimerNode;
                    bool            flag2 = true;
                    if (node5 != null)
                    {
                        if (!ActiveDreamNodeEx.OnCompletion(node5))
                        {
                            flag2 = false;
                        }
                        else if ((node5.IsRepeatable) && (ths.IsNotSpecialCaseNode(node5.NodeInstance.PrimitiveId) && ((node5.DebugCompleteFlags & ActiveDreamNode.DebugCompleteReasons.kStartNode) == ActiveDreamNode.DebugCompleteReasons.kNone)))
                        {
                            if (node5.NodeInstance.TimeBetweenRepeats <= 0f)
                            {
                                ths.CancelDream(node5);
                                node5.Reset(true);
                                flag2 = false;
                            }
                            else
                            {
                                node5.Reset(false);
                                ths.mSleepingNodes.Add(node5);
                            }
                        }
                    }
                    if ((node6 != null) && !node6.IsComplete)
                    {
                        flag2 = false;
                    }
                    if (flag2)
                    {
                        ths.RemoveActiveNode(base5);
                    }
                }

                List <ActiveDreamNode> list5 = new List <ActiveDreamNode>();
                foreach (ActiveDreamNode node7 in ths.mDreamNodes)
                {
                    if (node7.TimeActive > node7.NodeInstance.DisplayTime)
                    {
                        list5.Add(node7);
                    }
                }

                foreach (ActiveDreamNode node8 in list5)
                {
                    if ((ths.mDisplayedDreamNodes.Remove(node8) && (ths == DreamsAndPromisesManager.ActiveDreamsAndPromisesManager)) && (DreamsAndPromisesModel.Singleton != null))
                    {
                        DreamsAndPromisesModel.Singleton.FireRemoveDream(node8);
                    }
                    ths.mDreamNodes.Remove(node8);
                }

                if ((flag && (ths == DreamsAndPromisesManager.ActiveDreamsAndPromisesManager)) && (DreamsAndPromisesModel.Singleton != null))
                {
                    ths.RefreshDisplayedDreams();
                }

                if (ths.mShouldRefreshOnUpdate)
                {
                    ths.mShouldRefreshOnUpdate = false;

                    try
                    {
                        ths.Refresh();
                    }
                    catch (Exception e)
                    {
                        Common.Exception(ths.Actor, e);
                    }
                }
            }
        }
Exemplo n.º 14
0
 public void Restore(Sim sim)
 {
     try{
         bool dnpUpdated = (false);
         if (mDnPExportData != null)
         {
             sim.NullDnPManager();
             DreamsAndPromisesManager.CreateFromExportData(sim, mDnPExportData);
             sim.SimDescription.DnPExportData = null;
             dnpUpdated = (true);
         }
         else
         if (mDnpManager != null)
         {
             sim.NullDnPManager();
             sim.mDreamsAndPromisesManager = mDnpManager;
             dnpUpdated = (true);
         }
         if ((dnpUpdated) && (sim.DreamsAndPromisesManager != null))
         {
             OnLoadFixup(sim, mInitialStore);
             sim.DreamsAndPromisesManager.SetToUpdate(true, true);
         }
         if (mOpportunityManager != null)
         {
             if (sim.mOpportunityManager != null)
             {
                 sim.mOpportunityManager.CancelAllOpportunities();
                 sim.mOpportunityManager.TearDownLocationBasedOpportunities();
             }
             sim.mOpportunityManager = mOpportunityManager;
         }
         else
         if (sim.mOpportunityManager == null)
         {
             sim.mOpportunityManager = new OpportunityManager(sim);
             sim.mOpportunityManager.SetupLocationBasedOpportunities();
             if (sim.mOpportunitiesAlarmHandle == AlarmHandle.kInvalidHandle)
             {
                 sim.ScheduleOpportunityCall();
             }
         }
         try{
             if (mOppStore != null)
             {
                 mOppStore.Dispose();
             }
             if (sim.OpportunityManager != null)
             {
                 sim.OpportunityManager.Fixup();
             }
         }catch (Exception exception) {
             //  Get stack trace for the exception. with source file information
             var st = new StackTrace(exception, true);
             //  Get the top stack frame
             var frame = st.GetFrame(0);
             //  Get the line number from the stack frame
             var line = frame.GetFileLineNumber();
             Alive.WriteLog(exception.Message + "\n\n" +
                            exception.StackTrace + "\n\n" +
                            exception.Source + "\n\n" +
                            line);
         }finally{
         }
         //  [NRaas:]Remove the opportunity alarm for inactive sims, as there is no check for selectability within it
         if (sim.CelebrityManager != null)
         {
             sim.CelebrityManager.RemoveOppotunityAlarm();
         }
     }catch (Exception exception) {
         //  Get stack trace for the exception. with source file information
         var st = new StackTrace(exception, true);
         //  Get the top stack frame
         var frame = st.GetFrame(0);
         //  Get the line number from the stack frame
         var line = frame.GetFileLineNumber();
         Alive.WriteLog(exception.Message + "\n\n" +
                        exception.StackTrace + "\n\n" +
                        exception.Source + "\n\n" +
                        line);
     }finally{
     }
 }
Exemplo n.º 15
0
        public static string GetStatus(SimDescription sim)
        {
            string str = sim.FullName;

            bool serviceOrRole = false;

            if (sim.AssignedRole != null)
            {
                serviceOrRole = true;
                ShoppingRegister register = sim.AssignedRole.RoleGivingObject as ShoppingRegister;
                if (register != null)
                {
                    str += ", " + register.RegisterRoleName(sim.IsFemale);
                }
                else
                {
                    string roleName;
                    if (Localization.GetLocalizedString(sim.AssignedRole.CareerTitleKey, out roleName))
                    {
                        str += ", " + roleName;
                    }
                }

                string hours = GetRoleHours(sim);
                if (!string.IsNullOrEmpty(hours))
                {
                    str += Common.NewLine + hours;
                }
            }
            else if (SimTypes.InServicePool(sim))
            {
                serviceOrRole = true;

                string serviceName;
                if (Localization.GetLocalizedString("Ui/Caption/Services/Service:" + sim.CreatedByService.ServiceType.ToString(), out serviceName))
                {
                    str += ", " + serviceName;
                }
            }

            List <string> customTitles;

            if (Tagger.Settings.mCustomSimTitles.TryGetValue(sim.SimDescriptionId, out customTitles))
            {
                int perline = serviceOrRole ? 1 : 2;
                serviceOrRole = true;
                foreach (string title in customTitles)
                {
                    if (perline == 0)
                    {
                        str    += Common.NewLine;
                        perline = 3;
                    }
                    str += ", " + title;
                    perline--;
                }
            }

            if ((serviceOrRole) || (Tagger.Settings.mTagDataSettings[TagDataType.Orientation] && Tagger.Settings.mTagDataSettings[TagDataType.LifeStage] && (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.AgeInYears] || (Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage] && sim.AgingEnabled))))
            {
                str += Common.NewLine;
            }
            else
            {
                str += " - ";
            }

            if (!sim.IsPet)
            {
                if (sim.TeenOrAbove && Tagger.Settings.mTagDataSettings[TagDataType.Orientation])
                {
                    str += Common.Localize("SimType:" + TagDataHelper.GetOrientation(sim).ToString());
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.Zodiac] && sim.Zodiac != Zodiac.Unset)
                {
                    if (Tagger.Settings.mTagDataSettings[TagDataType.Orientation])
                    {
                        str += " ";
                    }

                    str += Common.LocalizeEAString("Ui/Caption/HUD/KnownInfoDialog:" + sim.Zodiac.ToString());
                }
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.LifeStage])
            {
                if (!sim.IsPet && Tagger.Settings.mTagDataSettings[TagDataType.Orientation] || (Tagger.Settings.mTagDataSettings[TagDataType.Zodiac] && sim.Zodiac != Zodiac.Unset))
                {
                    str += " ";
                }

                str += sim.AgeLocalizedText;
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.AgeInYears] || Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
            {
                str += " (";
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.AgeInYears])
            {
                str += Common.Localize("TagData:Age", sim.IsFemale);
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] && !Tagger.Settings.mTagDataSettings[TagDataType.AgeInYears])
            {
                str += " " + Common.Localize("TagData:Days", sim.IsFemale, new object[] { Math.Round(Aging.GetCurrentAgeInDays(sim as IMiniSimDescription)) });
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInYears])
            {
                str += " " + Common.Localize("TagData:Years", sim.IsFemale, new object[] { Math.Round(Aging.GetCurrentAgeInDays(sim as IMiniSimDescription) / Tagger.Settings.TagDataAgeInYearsLength) + 1 });
            }

            if (sim.AgingEnabled)
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
                {
                    str += ", " + Common.Localize("TagData:Birthday", sim.IsFemale, new object[] { (int)(AgingManager.Singleton.AgingYearsToSimDays(AgingManager.GetMaximumAgingStageLength(sim)) - AgingManager.Singleton.AgingYearsToSimDays(sim.AgingYearsSinceLastAgeTransition)) });
                }
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.AgeInDays] || Tagger.Settings.mTagDataSettings[TagDataType.AgeInYears] || Tagger.Settings.mTagDataSettings[TagDataType.DaysTillNextStage])
            {
                str += ")";
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.Occult] && sim.OccultManager != null)
            {
                List <OccultTypes> types = OccultTypeHelper.CreateList(sim, false);

                if (types.Count > 0)
                {
                    str += Common.NewLine;

                    string occultString = "";
                    foreach (OccultTypes type in types)
                    {
                        occultString += ", " + OccultTypeHelper.GetLocalizedName(type);
                    }

                    str += Common.Localize("TagData:OccultTag", sim.IsFemale, new object[] { occultString.Remove(0, 2) });
                }
            }

            Sim createdSim = sim.CreatedSim;

            if (Tagger.Settings.Debugging)
            {
                if (createdSim != null)
                {
                    str += Common.NewLine + "Autonomy: ";
                    if (createdSim.Autonomy == null)
                    {
                        str += "None";
                    }
                    else
                    {
                        if (createdSim.Autonomy.AutonomyDisabled)
                        {
                            str += "Disabled";
                        }
                        else if (!AutonomyRestrictions.IsAnyAutonomyEnabled(createdSim))
                        {
                            str += "User Disabled";
                        }
                        else if (createdSim.Autonomy.IsRunningHighLODSimulation)
                        {
                            str += "High";
                        }
                        else
                        {
                            str += "Low";
                        }

                        if (createdSim.Autonomy.ShouldRunLocalAutonomy)
                        {
                            str += " Local";
                        }

                        if (createdSim.CanRunAutonomyImmediately())
                        {
                            str += " Ready";
                        }
                        else if (!createdSim.mLastInteractionWasAutonomous)
                        {
                            str += " Push";
                        }
                        else if (!createdSim.mLastInteractionSucceeded)
                        {
                            str += " Fail";
                        }

                        if (createdSim.Autonomy.InAutonomyManagerQueue)
                        {
                            str += " Queued";
                        }
                    }
                }
            }

            if (createdSim != null)
            {
                if (Tagger.Settings.mTagDataSettings[TagDataType.Mood])
                {
                    str += Common.NewLine;
                    int flavour = (int)createdSim.MoodManager.MoodFlavor;

                    str += Common.Localize("TagData:MoodTag", sim.IsFemale, new object[] { Common.LocalizeEAString(false, "Ui/Tooltip/HUD/SimDisplay:MoodFlavor" + flavour.ToString()) }) + " ";
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.MotiveInfo])
                {
                    if (!Tagger.Settings.mTagDataSettings[TagDataType.Mood])
                    {
                        str += Common.NewLine;
                    }

                    string motives = ", ";
                    int    num     = 0;
                    foreach (CommodityKind kind in (Sims3.UI.Responder.Instance.HudModel as HudModel).GetMotives(sim.CreatedSim))
                    {
                        if (sim.CreatedSim.Motives.HasMotive(kind))
                        {
                            if (num >= 6)
                            {
                                break;
                            }

                            motives += FetchMotiveLocalization(sim.Species, kind) + ": " + "(" + sim.CreatedSim.Motives.GetValue(kind).ToString("0.") + ") ";
                        }

                        num++;
                    }

                    if (sim.CreatedSim.Motives.HasMotive(CommodityKind.Temperature))
                    {
                        motives += FetchMotiveLocalization(sim.Species, CommodityKind.Temperature) + ": " + "(" + sim.CreatedSim.Motives.GetValue(CommodityKind.Temperature).ToString("0.") + ") ";
                    }

                    str += Common.Localize("TagData:Motives", sim.IsFemale, new object[] { motives.Remove(0, 2) });
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.CurrentInteraction] && createdSim.CurrentInteraction != null)
                {
                    str += Common.NewLine;

                    try
                    {
                        str += createdSim.CurrentInteraction.ToString();
                    }
                    catch (Exception e)
                    {
                        Common.DebugException(createdSim, e);

                        str += createdSim.CurrentInteraction.GetType();
                    }

                    Tone tone = createdSim.CurrentInteraction.CurrentTone;
                    if (tone != null)
                    {
                        str += Common.NewLine + tone.ToString();
                    }

                    SocialInteractionBase social = createdSim.CurrentInteraction as SocialInteractionBase;
                    if ((social != null) && (social.Target != null))
                    {
                        str += " " + Common.Localize("TagData:With", sim.IsFemale, new object[] { social.Target.Name });
                    }

                    if (createdSim.CurrentInteraction is Terrain.GoHereWith)
                    {
                        InviteToLotSituation situtation = InviteToLotSituation.FindInviteToLotSituationInvolving(createdSim);
                        if (situtation != null)
                        {
                            if (situtation.SimA != createdSim)
                            {
                                str += " " + situtation.SimA.Name;
                            }
                            else if (situtation.SimB != createdSim)
                            {
                                str += situtation.SimB.Name;
                            }
                        }
                    }
                }
            }

            if (!SimTypes.IsSpecial(sim))
            {
                str += Common.NewLine + Common.Localize("TagData:CashTag", sim.IsFemale, new object[] { sim.FamilyFunds });

                if ((Tagger.Settings.mTagDataSettings[TagDataType.Debt] || Tagger.Settings.mTagDataSettings[TagDataType.NetWorth]) && sGetDebtAndNetworth.Valid)
                {
                    int bit = 0;
                    if (Tagger.Settings.mTagDataSettings[TagDataType.Debt])
                    {
                        bit = bit + 1;
                    }
                    if (Tagger.Settings.mTagDataSettings[TagDataType.NetWorth])
                    {
                        bit = bit + 4;
                    }

                    str += sGetDebtAndNetworth.Invoke <string>(new object[] { sim, bit });
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.LifetimeWant] && sim.HasLifetimeWish)
                {
                    IInitialMajorWish wish = DreamsAndPromisesManager.GetMajorDream(sim.LifetimeWish);

                    string completed = string.Empty;
                    if (sim.CreatedSim != null && sim.CreatedSim.DreamsAndPromisesManager != null)
                    {
                        ActiveDreamNode node = sim.CreatedSim.DreamsAndPromisesManager.LifetimeWishNode;
                        completed = " " + node.AmountCompleted;
                    }

                    if (wish != null)
                    {
                        str += Common.NewLine + Common.Localize("TagData:LifetimeWantTag", sim.IsFemale, new object[] { wish.GetMajorWishName(sim) }) + completed;
                    }
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.LifetimeHappiness] && sim.LifetimeHappiness > 0)
                {
                    if (!Tagger.Settings.mTagDataSettings[TagDataType.LifetimeWant] || (Tagger.Settings.mTagDataSettings[TagDataType.LifetimeWant] && !sim.HasLifetimeWish))
                    {
                        str += Common.NewLine;
                    }
                    else
                    {
                        str += " ";
                    }

                    str += Common.Localize("TagData:LifetimeHappinessSpendable", sim.IsFemale, new object[] { sim.LifetimeHappiness, sim.SpendableHappiness });
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.Job])
                {
                    if (sim.Occupation != null)
                    {
                        str += Common.NewLine;
                        if (sim.Occupation.OfficeLocation != null)
                        {
                            str += Common.Localize("TagData:JobAt", sim.IsFemale, new object[] { sim.Occupation.CurLevelJobTitle, sim.Occupation.OfficeLocation.GetLocalizedName() });
                        }
                        else
                        {
                            str += Common.Localize("TagData:JobTag", sim.IsFemale, new object[] { sim.Occupation.CurLevelJobTitle });
                        }
                    }
                }

                if (Tagger.Settings.mTagDataSettings[TagDataType.PartnerInfo])
                {
                    if (sim.Partner != null)
                    {
                        Relationship rel    = sim.GetRelationship(sim.Partner, false);
                        string       status = "Happily";
                        if (rel != null)
                        {
                            if (rel.CurrentLTRLiking < -15)
                            {
                                status = "Unhappily";
                            }
                        }

                        str += Common.NewLine;

                        if (sim.IsMarried)
                        {
                            str += Common.Localize("TagData:Spouse", sim.IsFemale, new object[] { Common.Localize("TagData:" + status), sim.Partner });
                        }
                        else
                        {
                            str += Common.Localize("TagData:Partner", sim.IsFemale, new object[] { sim.Partner });
                        }
                    }
                }
            }

            if (sim.IsPregnant && Tagger.Settings.mTagDataSettings[TagDataType.PregnancyInfo])
            {
                IMiniSimDescription father = SimDescription.Find(sim.Pregnancy.DadDescriptionId);
                if (father == null)
                {
                    father = MiniSimDescription.Find(sim.Pregnancy.DadDescriptionId);
                }

                str += Common.NewLine;

                if (father != null)
                {
                    if (sim.Partner != null && father != sim.Partner && !sim.IsPet)
                    {
                        string uhoh = Common.Localize("TagData:Uhoh");
                        str += Common.Localize("TagData:Pregnancy", sim.IsFemale, new object[] { father, uhoh });
                    }
                    else
                    {
                        str += Common.Localize("TagData:Pregnancy", sim.IsFemale, new object[] { father });
                    }
                }
                else
                {
                    str += Common.Localize("TagData:PregnancyUnknown", sim.IsFemale);
                }
            }

            if (Tagger.Settings.mTagDataSettings[TagDataType.PersonalityInfo] && sGetClanInfo.Valid)
            {
                List <string> info = sGetClanInfo.Invoke <List <string> >(new object [] { sim });
                foreach (string personality in info)
                {
                    str += Common.NewLine + personality;
                }
            }

            return(str);
        }
Exemplo n.º 16
0
        public DreamStore(Sim sim, bool initialStore, bool simpleRetain)
        {
            mInitialStore  = initialStore;
            mSim           = sim.SimDescription;
            mDnPExportData = null;
            bool storeDnP = (false);

            if ((sim.mDreamsAndPromisesManager != null) &&
                (sim.DreamsAndPromisesManager.mPromiseNodes != null))
            {
                foreach (ActiveDreamNode node in sim.DreamsAndPromisesManager.mPromiseNodes)
                {
                    if (node != null)
                    {
                        storeDnP = (true);
                        break;
                    }
                }
            }
            if (storeDnP)
            {
                OnLoadFixup(sim, false);
                if (simpleRetain)
                {
                    mDnpManager = sim.DreamsAndPromisesManager;
                    sim.mDreamsAndPromisesManager = null;
                }
                else
                {
                    try{
                        mDnPExportData = new DnPExportData(mSim);
                        sim.NullDnPManager();
                    }catch (Exception exception) {
                        //  Get stack trace for the exception. with source file information
                        var st = new StackTrace(exception, true);
                        //  Get the top stack frame
                        var frame = st.GetFrame(0);
                        //  Get the line number from the stack frame
                        var line = frame.GetFileLineNumber();
                        Alive.WriteLog(exception.Message + "\n\n" +
                                       exception.StackTrace + "\n\n" +
                                       exception.Source + "\n\n" +
                                       line);
                    }finally{
                    }
                }
            }

            if (sim.HasOpportunity())
            {
                foreach (Opportunity opp in sim.OpportunityManager.List)
                {
                    if (mSim.OpportunityHistory.GetCurrentOpportunity(opp.OpportunityCategory) == null)
                    {
                        mSim.OpportunityHistory.AddCurrentOpportunity(opp.OpportunityCategory,
                                                                      opp.Guid, null,
                                                                      opp.TargetObject as Sim,
                                                                      opp.ParentOpportunities,
                                                                      opp.TargetInteractionNumberItemsRequiredList(),
                                                                      opp.Name,
                                                                      opp.Description,
                                                                      opp.DeadlineString);
                    }
                }
                Alive.ResetClearSimTask.
                CleanupOpportunities(mSim, false);
                if (simpleRetain)
                {
                    mOpportunityManager = sim.OpportunityManager;
                }
                else
                {
                    mOppStore = new OpportunityStore(sim.SimDescription, true);
                }
                sim.mOpportunityManager = null;
            }
            else
            {
                mSim.NeedsOpportunityImport = false;
            }
        }
Exemplo n.º 17
0
        protected override bool PrivateUpdate(ScenarioFrame frame)
        {
            int autoToastDreams = GetValue <AutoToastDreamsOption, int>();

            if (autoToastDreams > 0)
            {
                if ((OldHouse != null) && (NewHouse != null))
                {
                    foreach (SimDescription sim in CommonSpace.Helpers.Households.All(NewHouse))
                    {
                        if (sim.CreatedSim == null)
                        {
                            continue;
                        }

                        DreamsAndPromisesManager dnpManager = sim.CreatedSim.DreamsAndPromisesManager;
                        if (dnpManager == null)
                        {
                            continue;
                        }

                        if (dnpManager.mDreamNodes == null)
                        {
                            continue;
                        }

                        int numPromised = dnpManager.NumPromisedDreams();

                        if (sim.LifetimeWishNode != null)
                        {
                            numPromised--;
                        }

                        if (numPromised > 0)
                        {
                            continue;
                        }

                        IncStat("Dropping Dreams");

                        int remainingToastDreams = autoToastDreams;
                        while ((remainingToastDreams > 0) &&
                               (dnpManager.mDreamNodes.Count > 0))
                        {
                            dnpManager.CancelDream(dnpManager.mDreamNodes[0]);

                            remainingToastDreams--;

                            IncStat("Dropped Starting Dream");
                        }
                    }
                }
            }

            UpdateAgingScenario updateAging = new UpdateAgingScenario();

            updateAging.Manager = Sims;

            updateAging.Perform(CommonSpace.Helpers.Households.All(NewHouse), frame);
            updateAging.Perform(CommonSpace.Helpers.Households.All(OldHouse), frame);
            return(false);
        }
Exemplo n.º 18
0
        public static bool OnCompletion(ActiveDreamNode ths)
        {
            DreamsAndPromisesManager manager = null;

            if (ths.Owner != null)
            {
                manager = ths.Owner.DreamsAndPromisesManager;
            }

            if (manager == null)
            {
                return(false);
            }

            // Changed
            if ((ths.IsPromised) ||
                ((manager.mDisplayedDreamNodes != null) && (manager.mDisplayedDreamNodes.Contains(ths))))
            {
                bool wasMajorDream = false;
                try
                {
                    if (ths.IsMajorWish && !ths.mOwner.SimDescription.HasCompletedLifetimeWish)
                    {
                        wasMajorDream = true;
                        ths.mOwner.SimDescription.HasCompletedLifetimeWish = true;
                        ths.mOwner.BuffManager.AddElement(BuffNames.Fulfilled, DreamsAndPromisesManager.kVeryFulfilledMoodValue, DreamsAndPromisesManager.kVeryFulfilledDuration, Origin.FromLifetimeWish);
                        (ths.mOwner.BuffManager.GetElement(BuffNames.Fulfilled) as BuffFulfilled.BuffInstanceFulfilled).SetVeryFulfilledText();
                    }
                    else
                    {
                        BuffFulfilled.BuffInstanceFulfilled element = ths.mOwner.BuffManager.GetElement(BuffNames.Fulfilled) as BuffFulfilled.BuffInstanceFulfilled;
                        if (element != null)
                        {
                            float num = element.mBuff.EffectValue + (BuffFulfilled.kFulfilledBuffStackTimes * BuffFulfilled.kFulfilledBuffStackMoodValue);
                            if (element.mEffectValue < num)
                            {
                                ths.mOwner.BuffManager.AddElement(BuffNames.Fulfilled, (int)(element.mEffectValue + BuffFulfilled.kFulfilledBuffStackMoodValue), Origin.FromCompletingPromisedWish);
                            }
                        }
                        else
                        {
                            ths.mOwner.BuffManager.AddElement(BuffNames.Fulfilled, Origin.FromCompletingPromisedWish);
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.DebugException(ths.Owner, e);
                }

                // Changed
                manager.RemoveDisplayedPromiseNode(ths);
                if (DreamsAndPromisesManager.IsMLCrisisDream(ths))
                {
                    MidlifeCrisisManager.MidlifeCrisisPromiseCompleted(ths.Owner.SimDescription);
                    MidlifeCrisisManager.UpdateCrisisType(ths.Owner.SimDescription);
                }

                if (ths.IsPromised)
                {
                    if ((manager == DreamsAndPromisesManager.ActiveDreamsAndPromisesManager) && (DreamsAndPromisesModel.Singleton != null))
                    {
                        DreamsAndPromisesModel.Singleton.FireFulfillPromise(ths);
                    }
                }

                float achievementPoints = ths.AchievementPoints;
                if (ths.mOwner.BuffManager.HasElement(BuffNames.WishMaster))
                {
                    achievementPoints *= DreamsAndPromisesManager.kWishMasterMultiple;
                }

                SimDescriptionEx.IncrementLifetimeHappiness(ths.Owner.SimDescription, achievementPoints);

                if (!Responder.Instance.EditTownModel.IsLoading)
                {
                    manager.PopRewardEffect(achievementPoints, wasMajorDream);
                }
                if (wasMajorDream)
                {
                    if (ths.Owner.IsEP11Bot)
                    {
                        if ((ths.Owner.SimDescription.TraitChipManager != null) && ths.Owner.SimDescription.TraitChipManager.HasElement(11L))
                        {
                            ths.Owner.ShowTNSIfSelectable(Localization.LocalizeString(ths.Owner.IsFemale, "Gameplay/DreamsAndPromises/DreamsAndPromisesManager:LifetimeWishSuccessTNS", new object[] { ths.Owner }), StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, ths.Owner.ObjectId);
                        }
                    }
                    else
                    {
                        ths.Owner.ShowTNSIfSelectable(Localization.LocalizeString(ths.Owner.IsFemale, "Gameplay/DreamsAndPromises/DreamsAndPromisesManager:LifetimeWishSuccessTNS", new object[] { ths.Owner }), StyledNotification.NotificationStyle.kGameMessagePositive, ObjectGuid.InvalidObjectGuid, ths.Owner.ObjectId);
                    }
                }

                EventTracker.SendEvent(new DreamEvent(EventTypeId.kPromisedDreamCompleted, ths, true));
            }

            return(true);
        }
Exemplo n.º 19
0
        protected bool PrivatePerform()
        {
            if (!Sims.Instantiate(Sim, null, false))
            {
                return(false);
            }

            if (Sim.CreatedSim == null)
            {
                return(false);
            }

            bool DnP = (Sim.CreatedSim.DreamsAndPromisesManager != null);

            bool success = false;

            if (!DnP)
            {
                bool hadWish = Sim.HasLifetimeWish;

                try
                {
                    DreamsAndPromisesManager.CreateAndIntitForSim(Sim.CreatedSim);
                }
                catch (Exception e)
                {
                    Common.DebugException(Sim, e);
                }

                if (!hadWish)
                {
                    Sim.LifetimeWish = ChooseRandomLifetimeWish(Sim.CreatedSim.DreamsAndPromisesManager);
                    if (Sim.HasLifetimeWish)
                    {
                        Sim.CreatedSim.DreamsAndPromisesManager.TryAddLifetimeWish();
                    }
                    success = true;
                }
            }

            if ((Sims.MatchesAlertLevel(Sim)) && (GetValue <PromptOption, bool>()))
            {
                if ((AcceptCancelDialog.Show(ManagerSim.GetPersonalInfo(Sim, Common.Localize("ChooseLifetimeWish:Prompt", Sim.IsFemale)))) && (LifetimeWants.SetLifetimeWant(Sim)))
                {
                    success = true;
                }
            }

            if (!success)
            {
                Sim.LifetimeWish = ChooseRandomLifetimeWish(Sim.CreatedSim.DreamsAndPromisesManager);
                if (Sim.HasLifetimeWish)
                {
                    Sim.CreatedSim.DreamsAndPromisesManager.TryAddLifetimeWish();
                }
            }

            IncStat("Set");

            if (!DnP)
            {
                Sim.CreatedSim.NullDnPManager();
            }

            return(true);
        }
Exemplo n.º 20
0
            public DreamStore(Sim sim, bool initialStore, bool simpleRetain)
            {
                mInitialStore = initialStore;

                mSim = sim.SimDescription;

                mDnPExportData = null;

                bool storeDnP = false;

                if ((sim.mDreamsAndPromisesManager != null) &&
                    (sim.DreamsAndPromisesManager.mPromiseNodes != null))
                {
                    foreach (ActiveDreamNode node in sim.DreamsAndPromisesManager.mPromiseNodes)
                    {
                        if (node != null)
                        {
                            storeDnP = true;
                            break;
                        }
                    }
                }

                if (storeDnP)
                {
                    OnLoadFixup(sim, false);

                    if (simpleRetain)
                    {
                        mDnpManager = sim.DreamsAndPromisesManager;
                        sim.mDreamsAndPromisesManager = null;
                    }
                    else
                    {
                        try
                        {
                            mDnPExportData = new DnPExportData(mSim);

                            sim.NullDnPManager();
                        }
                        catch (Exception e)
                        {
                            Common.Exception(mSim, e);
                        }
                    }
                }

                if (sim.HasOpportunity())
                {
                    foreach (Opportunity opp in sim.OpportunityManager.List)
                    {
                        if (mSim.OpportunityHistory.GetCurrentOpportunity(opp.OpportunityCategory) == null)
                        {
                            mSim.OpportunityHistory.AddCurrentOpportunity(opp.OpportunityCategory, opp.Guid, null, opp.TargetObject as Sim, opp.ParentOpportunities, opp.TargetInteractionNumberItemsRequiredList(), opp.Name, opp.Description, opp.DeadlineString);
                        }
                    }

                    Corrections.CleanupOpportunities(mSim, false, null);

                    if (simpleRetain)
                    {
                        mOpportunityManager = sim.OpportunityManager;
                    }
                    else
                    {
                        mOppStore = new OpportunityStore(sim.SimDescription, true);
                    }

                    sim.mOpportunityManager = null;
                }
                else
                {
                    mSim.NeedsOpportunityImport = false;
                }
            }
Exemplo n.º 21
0
        public override void Startup()
        {
            Common.StringBuilder msg = new Common.StringBuilder("LiveModeStateEx:Startup" + Common.NewLine);
            Traveler.InsanityWriteLog(msg);

            try
            {
                UIManager.BlackBackground(false);

                msg += "A1";
                Traveler.InsanityWriteLog(msg);

                // StateMachineState:Startup()
                mBaseCallFlag |= BaseCallFlag.kStartup;

                // InWorldSubState:Startup()
                while (sDelayNextStateStartupCount > 0x0)
                {
                    SpeedTrap.Sleep();
                }

                msg += "A2";
                Traveler.InsanityWriteLog(msg);

                EventTracker.SendEvent(new InWorldSubStateEvent(this, true));

                //base.Startup();

                msg += "A3";
                Traveler.InsanityWriteLog(msg);

                ShowUI(true);

                if (CameraController.IsMapViewModeEnabled() && !TutorialModel.Singleton.IsTutorialRunning())
                {
                    CameraController.EnableCameraMapView(true);
                }

                msg += "B";
                Traveler.InsanityWriteLog(msg);

                CASExitLoadScreen.Close();

                bool traveling = false;
                if (GameStates.IsTravelling)
                {
                    if (GameStates.sTravelData == null)
                    {
                        GameStates.ClearTravelStatics();
                    }
                    else
                    {
                        traveling = true;
                        GameStatesEx.OnArrivalAtVacationWorld();
                    }
                }

                msg += "C";
                Traveler.InsanityWriteLog(msg);

                if (GameStates.sNextSimToSelect != null)
                {
                    DreamCatcher.SelectNoLotCheckImmediate(GameStates.sNextSimToSelect, true, true);
                    GameStates.sNextSimToSelect = null;
                }

                msg += "D";
                Traveler.InsanityWriteLog(msg);

                bool flag2 = false;
                if (LoadingScreenController.Instance != null)
                {
                    if ((GameStates.IsPerfTestRunning || (CommandLine.FindSwitch("campos") != null)) || (CommandLine.FindSwitch("camtarget") != null))
                    {
                        msg += "D1";
                        Traveler.InsanityWriteLog(msg);

                        GameUtils.EnableSceneDraw(true);
                        LoadingScreenController.Unload();
                    }
                    else if (traveling)
                    {
                        msg += "D2";
                        Traveler.InsanityWriteLog(msg);

                        uint customFlyThroughIndex = CameraController.GetCustomFlyThroughIndex();
                        if (GameStates.IsNewGame && (customFlyThroughIndex != 0x0))
                        {
                            msg += "D3";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, false);
                            ShowUI(false);
                            ShowMaptags(false);

                            msg += "D4";
                            Traveler.InsanityWriteLog(msg);

                            AudioManager.MusicMode = MusicMode.Flyby;
                            CameraController.OnCameraFlyThroughFinishedCallback += OnCameraFlyThroughFinishedEvent;
                            CameraController.StartFlyThrough(customFlyThroughIndex, false);
                            flag2 = true;

                            msg += "D5";
                            Traveler.InsanityWriteLog(msg);

                            GameUtils.EnableSceneDraw(true);
                            LoadingScreenController.Unload();
                            while (LoadingScreenController.Instance != null)
                            {
                                Sleep(0.0);
                            }
                        }
                        else
                        {
                            msg += "D6";
                            Traveler.InsanityWriteLog(msg);

                            WaitForLotLoad(true, true);
                            Camera.SetView(CameraView.SimView, true, true);
                        }
                    }
                    else
                    {
                        msg += "D7";
                        Traveler.InsanityWriteLog(msg);

                        Camera.RestorePersistedState();

                        msg += "D8";
                        Traveler.InsanityWriteLog(msg);

                        WaitForLotLoad(false, true);
                    }
                }
                else if (traveling)
                {
                    msg += "D9";
                    Traveler.InsanityWriteLog(msg);

                    WaitForLotLoad(!GameUtils.IsUniversityWorld(), true);
                    Camera.SetView(CameraView.SimView, true, true);
                }

                msg += "E";
                Traveler.InsanityWriteLog(msg);

                UserToolUtils.UserToolGeneric(0xc8, new ResourceKey(0x0L, 0x0, 0x0));
                if (!flag2)
                {
                    GameUtils.Unpause();
                }

                if (AudioManager.MusicMode != MusicMode.Flyby)
                {
                    AudioManager.MusicMode = MusicMode.None;
                }

                msg += "F";
                Traveler.InsanityWriteLog(msg);

                InWorldSubState.EdgeScrollCheck();
                InWorldSubState.OpportunityDialogCheck();

                try
                {
                    DreamsAndPromisesManager.ValidateLifetimeWishes();
                }
                catch (Exception e)
                {
                    Common.Exception(msg, e);
                }

                LifeEventManager.ValidatePendingLifeEvents();
                if (GameUtils.IsInstalled(ProductVersion.EP9))
                {
                    Tutorialette.TriggerLesson(Lessons.Degrees, Sim.ActiveActor);
                }

                if (GameUtils.GetCurrentWorldType() == WorldType.Base)
                {
                    Tutorialette.TriggerLesson(Lessons.Traveling, Sim.ActiveActor);
                }

                if (Sims3.Gameplay.ActiveCareer.ActiveCareer.ActiveCareerShowGeneralLesson)
                {
                    Tutorialette.TriggerLesson(Lessons.Professions, Sim.ActiveActor);
                }

                msg += "G";
                Traveler.InsanityWriteLog(msg);

                Tutorialette.TriggerLesson(Lessons.AgingStageLengths, Sim.ActiveActor);

                Sim selectedActor = PlumbBob.SelectedActor;
                if (selectedActor != null)
                {
                    // Custom
                    if (GameStates.sMovingWorldData != null)
                    {
                        WorldData.MergeFromCrossWorldData();
                    }

                    if (selectedActor.LotHome != null)
                    {
                        if (selectedActor.LotHome.HasVirtualResidentialSlots)
                        {
                            Tutorialette.TriggerLesson(Lessons.ApartmentLiving, selectedActor);
                        }
                    }
                    else
                    {
                        Lot lot = Helpers.TravelUtilEx.FindLot();
                        if (lot != null)
                        {
                            lot.MoveIn(selectedActor.Household);

                            foreach (SimDescription sim in Households.All(selectedActor.Household))
                            {
                                if (sim.CreatedSim == null)
                                {
                                    FixInvisibleTask.Perform(sim, false);
                                }
                                else
                                {
                                    bool replace = (sim.CreatedSim == selectedActor);

                                    ResetSimTask.Perform(sim.CreatedSim, false);

                                    if (replace)
                                    {
                                        selectedActor = sim.CreatedSim;
                                    }
                                }
                            }

                            msg += "MoveIn";
                        }
                    }

                    if (selectedActor.Household != null)
                    {
                        foreach (SimDescription description in Households.Humans(selectedActor.Household))
                        {
                            // Custom
                            if (GameStates.sMovingWorldData != null)
                            {
                                CrossWorldControl.Restore(description);
                            }

                            if (description.Child || description.Teen)
                            {
                                Tutorialette.TriggerLesson(Lessons.Pranks, null);
                                break;
                            }
                        }
                    }

                    if (selectedActor.BuffManager != null)
                    {
                        BuffMummysCurse.BuffInstanceMummysCurse element = selectedActor.BuffManager.GetElement(BuffNames.MummysCurse) as BuffMummysCurse.BuffInstanceMummysCurse;
                        if (element != null)
                        {
                            BuffMummysCurse.SetCursedScreenFX(element.CurseStage, false);
                        }
                    }

                    if (selectedActor.CareerManager != null)
                    {
                        selectedActor.CareerManager.UpdateCareerUI();
                    }

                    if (Traveler.Settings.mAllowSpawnWeatherStone && GameUtils.IsInstalled(ProductVersion.EP7) && GameUtils.IsInstalled(ProductVersion.EP8))
                    {
                        Sims3.Gameplay.UI.Responder.Instance.TrySpawnWeatherStone();
                    }
                }

                msg += "H";
                Traveler.InsanityWriteLog(msg);

                // Custom
                if (GameStates.sMovingWorldData != null)
                {
                    GameStatesEx.UpdateMiniSims(GameStatesEx.GetAllSims());

                    foreach (SimDescription sim in Households.All(Household.ActiveHousehold))
                    {
                        MiniSimDescription miniSim = MiniSimDescription.Find(sim.SimDescriptionId);
                        if (miniSim != null)
                        {
                            miniSim.Instantiated = true;
                            if (miniSim.HomeWorld != GameUtils.GetCurrentWorld())
                            {
                                miniSim.HomeWorld = GameUtils.GetCurrentWorld();
                            }
                        }

                        if (sim.HomeWorld != GameUtils.GetCurrentWorld())
                        {
                            sim.HomeWorld = GameUtils.GetCurrentWorld();
                        }
                    }
                }

                GameStates.SetupPostMoveData();
                GameStates.ClearMovingData();
                MovingWorldsWizardCheck();

                // Custom
                Household.IsTravelImport = false;

                InWorldSubStateEx.PlaceLotWizardCheck(this);

                msg += "I";
                Traveler.InsanityWriteLog(msg);

                foreach (Sim sim in LotManager.Actors)
                {
                    try
                    {
                        if (sim.HasBeenDestroyed)
                        {
                            continue;
                        }

                        OccultManager occultManager = sim.OccultManager;
                        if (occultManager != null)
                        {
                            occultManager.RestoreOccultIfNecessary();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, null, msg, e);
                    }
                }

                msg += "J";
                Traveler.InsanityWriteLog(msg);

                // Custom
                foreach (SimDescription description in SimListing.GetResidents(false).Values)
                {
                    if (description.LotHome == null)
                    {
                        continue;
                    }

                    MiniSimDescription miniSimDescription = description.GetMiniSimDescription();
                    if (miniSimDescription != null)
                    {
                        miniSimDescription.LotHomeId = description.LotHome.LotId;
                    }
                }

                msg += "K";
                Traveler.InsanityWriteLog(msg);
            }
            catch (Exception e)
            {
                Traveler.InsanityException(msg, e);
            }
            finally
            {
                CASExitLoadScreen.Close();
            }
        }
Exemplo n.º 22
0
            public void Restore(Sim sim)
            {
                try
                {
                    bool dnpUpdated = false;

                    if (mDnPExportData != null)
                    {
                        sim.NullDnPManager();

                        DreamsAndPromisesManager.CreateFromExportData(sim, mDnPExportData);
                        sim.SimDescription.DnPExportData = null;

                        dnpUpdated = true;
                    }
                    else if (mDnpManager != null)
                    {
                        sim.NullDnPManager();

                        sim.mDreamsAndPromisesManager = mDnpManager;

                        dnpUpdated = true;
                    }

                    if ((dnpUpdated) && (sim.DreamsAndPromisesManager != null))
                    {
                        OnLoadFixup(sim, mInitialStore);

                        sim.DreamsAndPromisesManager.SetToUpdate(true, true);
                    }

                    if (mOpportunityManager != null)
                    {
                        if (sim.mOpportunityManager != null)
                        {
                            sim.mOpportunityManager.CancelAllOpportunities();
                            sim.mOpportunityManager.TearDownLocationBasedOpportunities();
                        }

                        sim.mOpportunityManager = mOpportunityManager;
                    }
                    else if (sim.mOpportunityManager == null)
                    {
                        sim.mOpportunityManager = new OpportunityManager(sim);
                        sim.mOpportunityManager.SetupLocationBasedOpportunities();

                        if (sim.mOpportunitiesAlarmHandle == AlarmHandle.kInvalidHandle)
                        {
                            sim.ScheduleOpportunityCall();
                        }
                    }

                    try
                    {
                        if (mOppStore != null)
                        {
                            mOppStore.Dispose();
                        }

                        if (sim.OpportunityManager != null)
                        {
                            sim.OpportunityManager.Fixup();
                        }
                    }
                    catch (Exception e)
                    {
                        Common.Exception(sim, e);
                    }

                    // Remove the opportunity alarm for inactive sims, as there is no check for selectability within it
                    if (sim.CelebrityManager != null)
                    {
                        sim.CelebrityManager.RemoveOppotunityAlarm();
                    }
                }
                catch (Exception e)
                {
                    Common.DebugException(sim, e);
                }
            }
Exemplo n.º 23
0
        public static void PartialUpdate(DreamsAndPromisesManager ths)
        {
            List<ActiveDreamNode> activeNodes = new List<ActiveDreamNode>(ths.mCompletedNodes);

            Dictionary<Event, List<DreamsAndPromisesManager.ScoredNode>> completedNodes = new Dictionary<Event, List<DreamsAndPromisesManager.ScoredNode>>();
            foreach (ActiveDreamNode node in activeNodes)
            {
                if ((node.CompletionEvent != null) && !completedNodes.ContainsKey(node.CompletionEvent))
                {
                    completedNodes.Add(node.CompletionEvent, new List<DreamsAndPromisesManager.ScoredNode>());
                }
            }

            foreach (ActiveDreamNode node2 in activeNodes)
            {
                List<DreamsAndPromisesManager.ScoredNode> list;
                if ((node2.PromiseParent != null) && (node2.PromiseParent.WasPromisedAndBroken || node2.PromiseParent.IsComplete))
                {
                    continue;
                }

                if ((node2.CompletionEvent == null) || !completedNodes.TryGetValue(node2.CompletionEvent, out list))
                {
                    list = new List<DreamsAndPromisesManager.ScoredNode>();
                    completedNodes.Add(new Event(EventTypeId.kEventNone), list);
                }

                try
                {
                    list.AddRange(ths.ScoreChildren(node2, completedNodes, false, node2.GetNonPromiseLinkChildren()));
                }
                catch(Exception e)
                {
                    Common.DebugException(ths.Actor, e);
                }
            }

            bool flag = ths.SelectDreamsToDisplay(completedNodes);
            foreach (ActiveDreamNode node3 in activeNodes)
            {
                bool flag2 = true;
                if (!ActiveDreamNodeEx.OnCompletion(node3))
                {
                    flag2 = false;
                }
                else if ((node3.IsRepeatable) && (ths.IsNotSpecialCaseNode(node3.NodeInstance.PrimitiveId) && ((node3.DebugCompleteFlags & ActiveDreamNode.DebugCompleteReasons.kStartNode) == ActiveDreamNode.DebugCompleteReasons.kNone)))
                {
                    if (node3.NodeInstance.TimeBetweenRepeats <= 0f)
                    {
                        ths.CancelDream(node3);
                        node3.Reset(true);
                        flag2 = false;
                    }
                    else
                    {
                        node3.Reset(false);
                        ths.mSleepingNodes.Add(node3);
                    }
                }
                if (flag2)
                {
                    ths.RemoveActiveNode(node3);
                }
            }

            if ((flag && (ths == DreamsAndPromisesManager.ActiveDreamsAndPromisesManager)) && (DreamsAndPromisesModel.Singleton != null))
            {
                ths.RefreshDisplayedDreams();
            }

            if (ths.mShouldRefreshOnUpdate)
            {
                ths.mShouldRefreshOnUpdate = false;

                try
                {
                    ths.Refresh();
                }
                catch (Exception e)
                {
                    Common.Exception(ths.Actor, e);
                }
            }
            ths.mCompletedNodes.Clear();
        }