Example #1
0
        public static SimDescription UnpackSim(MiniSimDescription ths, bool updateGenealogy)
        {
            try
            {
                if (ths == null)
                {
                    return(null);
                }

                // Calling ImportSimDescription prior to the Aging Manager being available is invalid, don't allow it
                if (AgingManager.Singleton == null)
                {
                    return(null);
                }

                SimDescription             desc      = new SimDescription();
                ResourceKeyContentCategory installed = ResourceKeyContentCategory.kInstalled;

                DownloadContent.ImportSimDescription(ths.mTravelKey, desc, ref installed);

                desc.SimDescriptionId = ths.mSimDescriptionId;

                if (desc.CareerManager != null)
                {
                    // Fixup for careers require a household, which is not set until later in this process

                    desc.CareerManager.mJob    = null;
                    desc.CareerManager.mSchool = null;
                }

                desc.Fixup();

                if (updateGenealogy && !GameStates.IsTravelling)
                {
                    if (desc.DefaultOutfitKey == ResourceKey.kInvalidResourceKey)
                    {
                        SimOutfit outfit = desc.GetOutfit(OutfitCategories.Everyday, 0x0);
                        if ((outfit == null) || (!outfit.IsValid))
                        {
                            desc.Dispose(false, false);
                            return(null);
                        }

                        desc.UpdateFromOutfit(OutfitCategories.Everyday);
                    }
                    desc.CASGenealogy = ths.CASGenealogy;
                }

                Corrections.CleanupBrokenSkills(desc, null);

                OccultTypeHelper.ValidateOccult(desc, null);

                return(desc);
            }
            catch (Exception e)
            {
                Common.Exception(ths.FullName, e);
                return(null);
            }
        }