Exemplo n.º 1
0
 public SafeStore(SimDescription sim, Flag flags)
 {
     mSim                   = sim;
     mNeverSelectable       = mSim.IsNeverSelectable;
     mSim.IsNeverSelectable = false;
     mFlags                 = flags;
     if ((mFlags & Flag.StoreOpportunities) == Flag.StoreOpportunities)
     {
         mOpportunities = new OpportunityStore(mSim, false);
     }
     mRole = mSim.AssignedRole;
     if ((flags & Flag.OnlyAcademic) == Flag.OnlyAcademic)
     {
         if (!GameUtils.IsUniversityWorld())
         {
             //  [NRaas:]Bypass for a removal during OnBecameSelectable()
             mCareer = mSim.OccupationAsAcademicCareer;
         }
     }
     else
     {
         mCareer = mSim.Occupation;
     }
     if (mCareer != null)
     {
         mSim.CareerManager.mJob = null;
     }
     if ((mSim.CareerManager != null) && ((flags & Flag.School) == Flag.School))
     {
         mSchool = mSim.CareerManager.School;
         if (mSchool != null)
         {
             mSim.CareerManager.mSchool = null;
         }
     }
     mSim.AssignedRole = null;
 }
Exemplo n.º 2
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.º 3
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;
            }
        }