Esempio n. 1
0
        public static void Flush(ExportBinContents ths)
        {
            switch (ths.mExportBinType)
            {
            case ExportBinType.Household:
                if (ths.mHouseholdContents != null)
                {
                    DownloadContent.DeleteHouseholdContents(ths.mHouseholdContents.ContentId);
                }
                ths.mHouseholdContents = null;
                break;

            case ExportBinType.HouseholdLot:
                if (ths.mLotContents != null)
                {
                    DownloadContent.DeleteLotContents(ths.mLotContents.ContentId);
                }
                ths.mLotContents       = null;
                ths.mHouseholdContents = null;
                break;

            case ExportBinType.Lot:
                if (ths.mLotContents != null)
                {
                    DownloadContent.DeleteLotContents(ths.mLotContents.ContentId);
                }
                ths.mLotContents       = null;
                ths.mHouseholdContents = null;
                break;
            }

            Household.CleanupOldIdToNewSimDescriptionMap();
        }
Esempio n. 2
0
        public static bool PayForLot(EditTownModel ths, UIBinInfo info, ulong lotId)
        {
            Lot lot = LotManager.GetLot(lotId);

            if (lot != null)
            {
                ExportBinContents contents = ths.FindExportBinContents(info.ContentId);
                if (contents != null)
                {
                    bool flag = contents.IsLoaded();
                    if (!flag)
                    {
                        ExportBinContentsEx.Import(contents, true);
                    }

                    Household household = contents.Household;
                    if (household != null)
                    {
                        return(BinCommonEx.PayForLot(household, lot, true, Mover.GetLotCost));
                    }

                    if (!flag)
                    {
                        ExportBinContentsEx.Flush(contents);
                    }
                }
                else if (info.LotId != ulong.MaxValue)
                {
                    LotContents contents2 = Bin.Singleton.FindLot(info.LotId);
                    if ((contents2 != null) && (contents2.Household != null))
                    {
                        Household household2 = contents2.Household.Household;
                        if (household2 != null)
                        {
                            return(BinCommonEx.PayForLot(household2, lot, true, Mover.GetLotCost));
                        }
                    }
                }
                else if (info.HouseholdId != ulong.MaxValue)
                {
                    Household household3 = Household.Find(info.HouseholdId);
                    if (household3 != null)
                    {
                        return(BinCommonEx.PayForLot(household3, lot, true, Mover.GetLotCost));
                    }
                }
            }
            return(false);
        }
Esempio n. 3
0
        public static void Import(ExportBinContents ths, bool origImport)
        {
            switch (ths.mExportBinType)
            {
            case ExportBinType.Household:
                ulong lotId = DownloadContent.ImportHouseholdContentsFromExportBin(ths.mPackageName);
                if (lotId != 0x0L)
                {
                    // Custom
                    HouseholdContentsProxy proxy = new HouseholdContentsProxy();
                    if (DownloadContent.ImportHouseholdContents(proxy, lotId))
                    {
                        ths.mHouseholdContents           = proxy.Contents;
                        ths.mHouseholdContents.ContentId = lotId;
                    }
                }
                break;

            case ExportBinType.HouseholdLot:
            case ExportBinType.Lot:
                ulong oldLotContentId = 0x0L;
                ulong lotContendId    = DownloadContent.ImportLotContentsFromExportBin(ths.mPackageName, ref oldLotContentId);
                if (lotContendId != 0x0L)
                {
                    if (ths.mExportBinType == ExportBinType.HouseholdLot)
                    {
                        // Custom
                        HouseholdContentsProxy proxy = new HouseholdContentsProxy();
                        ths.mHouseholdContents = proxy.Contents;

                        if (DownloadContent.ImportHouseholdContents(proxy, lotContendId))
                        {
                            ths.mHouseholdContents.ContentId = lotContendId;
                        }
                    }

                    LotContents contents2 = new LotContents(ths.mPackageName, lotContendId, ths.mHouseholdContents, ths.mLotContentsWorth, ths.LotType, ths.LotContentsSizeX, ths.LotContentsSizeY, ths.IsHouseboatLot, ths.mLotMaxLevel, oldLotContentId, ths.mResidentialLotSubType, ths.mCommercialLotSubType);
                    ths.mLotContents = contents2;
                }
                break;
            }

            if (origImport || (ths.mIndexMap == null))
            {
                ths.mIndexMap = CreateIndexMap(ths.Household);
            }
        }
Esempio n. 4
0
        public static void Import(ExportBinContents ths, bool origImport)
        {
            switch (ths.mExportBinType)
            {
                case ExportBinType.Household:
                    ulong lotId = DownloadContent.ImportHouseholdContentsFromExportBin(ths.mPackageName);
                    if (lotId != 0x0L)
                    {
                        // Custom
                        HouseholdContentsProxy proxy = new HouseholdContentsProxy();
                        if (DownloadContent.ImportHouseholdContents(proxy, lotId))
                        {
                            ths.mHouseholdContents = proxy.Contents;
                            ths.mHouseholdContents.ContentId = lotId;
                        }
                    }
                    break;
                case ExportBinType.HouseholdLot:
                case ExportBinType.Lot:
                    ulong oldLotContentId = 0x0L;
                    ulong lotContendId = DownloadContent.ImportLotContentsFromExportBin(ths.mPackageName, ref oldLotContentId);
                    if (lotContendId != 0x0L)
                    {
                        if (ths.mExportBinType == ExportBinType.HouseholdLot)
                        {
                            // Custom
                            HouseholdContentsProxy proxy = new HouseholdContentsProxy();
                            ths.mHouseholdContents = proxy.Contents;

                            if (DownloadContent.ImportHouseholdContents(proxy, lotContendId))
                            {
                                ths.mHouseholdContents.ContentId = lotContendId;
                            }
                        }

                        LotContents contents2 = new LotContents(ths.mPackageName, lotContendId, ths.mHouseholdContents, ths.mLotContentsWorth, ths.LotType, ths.LotContentsSizeX, ths.LotContentsSizeY, ths.IsHouseboatLot, ths.mLotMaxLevel, oldLotContentId, ths.mResidentialLotSubType, ths.mCommercialLotSubType);
                        ths.mLotContents = contents2;
                    }
                    break;
            }

            if (origImport || (ths.mIndexMap == null))
            {
                ths.mIndexMap = CreateIndexMap(ths.Household);
            }
        }
Esempio n. 5
0
        protected bool ValidContent(ExportBinContents content)
        {
            if (mDisallowed.Contains(content.PackageName))
            {
                return(false);
            }

            if ((content.HouseholdSims == null) || (content.HouseholdSims.Count == 0))
            {
                return(false);
            }

            if (content.HouseholdSims.Count > Manager.GetValue <MaximumBinHouseSizeOption <TManager>, int>())
            {
                return(false);
            }

            return(true);
        }
Esempio n. 6
0
        public static PlaceResult PlaceFromExportBin(ExportBinContents exportBinItem, Lot lot, PlaceAction action, bool buyFurnished, GetLotCost onLotCost, ref Sim newActiveSim)
        {
            if (exportBinItem == null)
            {
                return(PlaceResult.ContentFailure);
            }

            bool flag = exportBinItem.IsLoaded();

            if (!flag)
            {
                ExportBinContentsEx.Import(exportBinItem, false);
            }

            PlaceResult result = PlaceFromExportBin(exportBinItem.Household, exportBinItem, lot, action, buyFurnished, onLotCost, ref newActiveSim);

            if (!flag)
            {
                ExportBinContentsEx.Flush(exportBinItem);
            }

            return(result);
        }
Esempio n. 7
0
        public static PlaceResult PlaceFromExportBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action, bool showConfirmDialog)
        {
            try
            {
                PlaceResult contentFailure = PlaceResult.ContentFailure;
                Lot         lot            = LotManager.GetLot(lotId);
                if (lot == null)
                {
                    return(PlaceResult.InvalidLot);
                }

                ExportBinContents exportBinItem = ths.FindExportBinContents(info.ContentId);
                if (exportBinItem != null)
                {
                    ths.GetInWorldHouseholdBinInfoList();
                    ths.GetInWorldLotBinInfoList();
                    Sim newActiveSim = null;
                    if (lot.Household != null)
                    {
                        return(BinCommonEx.MergeHouseholdFromExportBin(exportBinItem, lot, showConfirmDialog, Mover.Settings.mAllowGreaterThanEight));
                    }

                    BinCommon.KickSimsOffLot(lot, true);
                    ProgressDialog.Show(Localization.LocalizeString("Ui/Caption/Global:Processing", new object[0x0]));

                    try
                    {
                        try
                        {
                            contentFailure = BinCommonEx.PlaceFromExportBin(exportBinItem, lot, action, true, Mover.GetLotCost, ref newActiveSim);

                            ExportBinContentsEx.Flush(exportBinItem);

                            UIBinInfo item = BinCommon.CreateInWorldBinInfo(lot.Household, lot);
                            if (item != null)
                            {
                                if (info.HouseholdId != ulong.MaxValue)
                                {
                                    ths.mInWorldHouseholdBin.Add(item);
                                }
                                else
                                {
                                    ths.mInWorldLotBin.Add(item);
                                }
                            }
                        }
                        finally
                        {
                            ProgressDialog.Close();
                        }
                    }
                    catch (ExecutionEngineException)
                    { }
                }
                return(contentFailure);
            }
            catch (Exception e)
            {
                Common.Exception("PlaceFromExportBin", e);
                return(PlaceResult.ContentFailure);
            }
        }
Esempio n. 8
0
        protected SimDescription GetSim(CASAgeGenderFlags gender, CASAgeGenderFlags species, SimDescription exclude)
        {
            if (RandomUtil.RandomChance(mBinChance))
            {
                List <ExportBinContents> contents = new List <ExportBinContents>();
                foreach (IExportBinContents iContent in BinModel.Singleton.ExportBinContents)
                {
                    ExportBinContents content = iContent as ExportBinContents;
                    if (content == null)
                    {
                        continue;
                    }

                    contents.Add(content);
                }

                Dictionary <UISimInfo, ExportBinContents> uiSims = new Dictionary <UISimInfo, ExportBinContents>();

                if (Manager.GetValue <EqualBinChanceOption <TManager>, bool>())
                {
                    foreach (ExportBinContents content in contents)
                    {
                        if (!ValidContent(content))
                        {
                            continue;
                        }

                        foreach (UISimInfo sim in content.HouseholdSims)
                        {
                            if (!ValidContent(sim, species, exclude))
                            {
                                continue;
                            }

                            if (uiSims.ContainsKey(sim))
                            {
                                continue;
                            }

                            uiSims.Add(sim, content);
                        }
                    }
                }
                else
                {
                    RandomUtil.RandomizeListOfObjects(contents);
                    foreach (ExportBinContents content in contents)
                    {
                        if (!ValidContent(content))
                        {
                            continue;
                        }

                        foreach (UISimInfo sim in content.HouseholdSims)
                        {
                            if (!ValidContent(sim, species, exclude))
                            {
                                continue;
                            }

                            uiSims.Add(sim, content);
                        }

                        if (uiSims.Count > 0)
                        {
                            break;
                        }
                    }
                }

                if (uiSims.Count > 0)
                {
                    UISimInfo choice = RandomUtil.GetRandomObjectFromList(new List <UISimInfo>(uiSims.Keys));

                    ExportBinContents content = uiSims[choice];

                    if (!content.IsLoaded())
                    {
                        Dictionary <string, List <News.NewsTuning.ArticleTuning> > namedArticles = News.sNewsTuning.mNamedArticles;

                        bool fail = false;
                        try
                        {
                            // Doing so stops Marriage notices of imported sims from appearing in the newspaper
                            News.sNewsTuning.mNamedArticles = new Dictionary <string, List <News.NewsTuning.ArticleTuning> >();

                            ExportBinContentsEx.Import(content, false);

                            mStats.AddStat("Import Size", content.HouseholdSims.Count);
                        }
                        catch (Exception e)
                        {
                            Common.DebugException(content.HouseholdName, e);
                            fail = true;
                        }
                        finally
                        {
                            News.sNewsTuning.mNamedArticles = namedArticles;
                        }

                        mLoaded[content] = true;

                        if (fail)
                        {
                            return(null);
                        }
                    }

                    if ((content.Household != null) && (content.Household.AllSimDescriptions.Count > 0))
                    {
                        List <SimDescription> choices = new List <SimDescription>();

                        foreach (SimDescription sim in Households.All(content.Household))
                        {
                            if (SimTypes.IsSkinJob(sim))
                            {
                                continue;
                            }

                            if (SimTypes.IsOccult(sim, OccultTypes.ImaginaryFriend))
                            {
                                continue;
                            }

                            mStats.IncStat("Immigrant: Bin Sim");

                            if (sim.Species == choice.Species)
                            {
                                choices.Add(sim);

                                if (sim.FullName == choice.SimName)
                                {
                                    return(sim);
                                }
                            }
                        }

                        if (choices.Count > 0)
                        {
                            return(RandomUtil.GetRandomObjectFromList(choices));
                        }
                    }
                }
            }

            if ((RandomUtil.RandomChance(mRandomChance)) || (Manager.Sims.All.Count <= 20))
            {
                return(GetRandomSim(gender, species));
            }

            List <SimDescription> sims = new List <SimDescription>();

            bool allowAlien = Manager.GetValue <AllowAlienHouseholdOption <TManager>, bool>();

            foreach (SimDescription sim in Manager.Sims.All)
            {
                if (SimTypes.InServicePool(sim, ServiceType.GrimReaper))
                {
                    continue;
                }

                if (sim.Species != species)
                {
                    continue;
                }

                if (!allowAlien)
                {
                    if (SimTypes.IsServiceAlien(sim))
                    {
                        continue;
                    }
                }

                if (exclude != null)
                {
                    if (exclude == sim)
                    {
                        continue;
                    }

                    if (exclude.LastName == sim.LastName)
                    {
                        continue;
                    }
                }

                sims.Add(sim);
            }

            if (sims.Count == 0)
            {
                return(null);
            }
            else
            {
                mStats.IncStat("Immigrant: Town Sim");

                return(RandomUtil.GetRandomObjectFromList(sims));
            }
        }
Esempio n. 9
0
        public static void Flush(ExportBinContents ths)
        {
            switch (ths.mExportBinType)
            {
                case ExportBinType.Household:
                    if (ths.mHouseholdContents != null)
                    {
                        DownloadContent.DeleteHouseholdContents(ths.mHouseholdContents.ContentId);
                    }
                    ths.mHouseholdContents = null;
                    break;
                case ExportBinType.HouseholdLot:
                    if (ths.mLotContents != null)
                    {
                        DownloadContent.DeleteLotContents(ths.mLotContents.ContentId);
                    }
                    ths.mLotContents = null;
                    ths.mHouseholdContents = null;
                    break;
                case ExportBinType.Lot:
                    if (ths.mLotContents != null)
                    {
                        DownloadContent.DeleteLotContents(ths.mLotContents.ContentId);
                    }
                    ths.mLotContents = null;
                    ths.mHouseholdContents = null;
                    break;
            }

            Household.CleanupOldIdToNewSimDescriptionMap();
        }
Esempio n. 10
0
        public static PlaceResult PlaceFromExportBin(Household household, ExportBinContents exportBinItem, Lot lot, PlaceAction action, bool buyFurnished, GetLotCost onLotCost, ref Sim newActiveSim)
        {
            if (household == null)
            {
                return(PlaceResult.InvalidBinHousehold);
            }
            else if (lot == null)
            {
                return(PlaceResult.InvalidLot);
            }
            else if (exportBinItem == null)
            {
                return(PlaceResult.ContentFailure);
            }

            bool flag = exportBinItem.IsLoaded();

            if (!flag)
            {
                ExportBinContentsEx.Import(exportBinItem, false);
            }

            PlaceResult contentFailure = PlaceResult.ContentFailure;

            if (household != null)
            {
                if (((action & PlaceAction.PlaceAndPay) != PlaceAction.PlaceOnly) && !PayForLot(household, lot, buyFurnished, onLotCost))
                {
                    if (!flag)
                    {
                        ExportBinContentsEx.Flush(exportBinItem);
                    }
                    Household.CleanupOldIdToNewSimDescriptionMap();
                    return(PlaceResult.InsufficientFunds);
                }

                if ((!buyFurnished) && (!lot.IsApartmentLot))
                {
                    lot.MakeLotUnfurnished();
                    Common.Sleep();
                    lot.UpdateCachedValues();
                }

                CreateActors(household, lot, false);
                CreateInventories(household, exportBinItem.HouseholdContents, exportBinItem.IndexMap);
                Common.Sleep();
                BinCommon.UpdateImportedUrnstones(household, lot);
                household.PostImport();

                if ((action & PlaceAction.MoveIn) != PlaceAction.PlaceOnly)
                {
                    BinCommon.MoveIn(household, lot);
                }
                if ((action & PlaceAction.Activate) != PlaceAction.PlaceOnly)
                {
                    newActiveSim = BinCommon.ActivateSim(exportBinItem.Household, lot);
                }

                ThumbnailManager.GenerateHouseholdThumbnail(household.HouseholdId, household.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);
                contentFailure = PlaceResult.Success;
            }

            if (!flag)
            {
                ExportBinContentsEx.Flush(exportBinItem);
            }

            return(contentFailure);
        }
Esempio n. 11
0
        public static PlaceResult MergeHouseholdFromExportBin(ExportBinContents exportBinItem, Lot lot, bool showConfirmDialog, bool allowOverstuff)
        {
            try
            {
                if (exportBinItem == null)
                {
                    return(PlaceResult.ContentFailure);
                }

                bool flag = exportBinItem.IsLoaded();
                if (!flag)
                {
                    ExportBinContentsEx.Import(exportBinItem, false);
                }

                PlaceResult householdPresent = PlaceResult.HouseholdPresent;
                Household   household        = exportBinItem.Household;
                Household   otherHouse       = lot.Household;
                if (household == null)
                {
                    householdPresent = PlaceResult.InvalidBinHousehold;
                }

                if (lot == null)
                {
                    householdPresent = PlaceResult.InvalidLot;
                }

                if (exportBinItem == null)
                {
                    householdPresent = PlaceResult.ContentFailure;
                }

                try
                {
                    try
                    {
                        if (((household != null) && (householdPresent == PlaceResult.HouseholdPresent)) && (otherHouse != null))
                        {
                            // Custom
                            if ((!allowOverstuff) && (!household.CanMergeWithHousehold(otherHouse, false)))
                            {
                                SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown:MergeWarning"), Common.LocalizeEAString("Ui/Caption/MovingDialog:TooManySims"));
                            }
                            // Custom
                            else if ((!allowOverstuff) && (!household.CanMergeWithHousehold(otherHouse, true)))
                            {
                                SimpleMessageDialog.Show(Common.LocalizeEAString("Ui/Caption/GameEntry/EditTown:MergeWarning"), Common.LocalizeEAString("Ui/Caption/MovingDialog:TooManySims_Pregnant"));
                            }
                            else if (!showConfirmDialog || PlayFlowConfirmMergePetHousehold.Show(BinCommon.CreateInWorldBinInfo(lot.LotId), exportBinItem.BinInfo))
                            {
                                ProgressDialog.Show(Common.LocalizeEAString("Ui/Caption/Global:Processing"));

                                otherHouse.ModifyFamilyFunds(household.FamilyFunds);

                                List <SimDescription> simDescs = new List <SimDescription>();
                                foreach (SimDescription description in household.AllSimDescriptions)
                                {
                                    simDescs.Add(description);
                                }

                                CreateActors(simDescs, null, false);
                                BinCommon.CreateFamilyInventories(household, exportBinItem.HouseholdContents);
                                BinCommon.MoveInventoryInto(household, otherHouse);
                                household.PostImport();

                                List <Sim> sims = new List <Sim>();
                                foreach (SimDescription description2 in simDescs)
                                {
                                    otherHouse.AddSim(description2.CreatedSim);
                                    sims.Add(description2.CreatedSim);
                                }

                                otherHouse.AddWardrobeToWardrobe(household.Wardrobe);
                                otherHouse.AddServiceUniforms(household.ServiceUniforms);
                                CreateSimInventories(simDescs, exportBinItem.HouseholdContents, exportBinItem.IndexMap);
                                BinCommon.PlaceSims(sims, lot);
                                ThumbnailManager.GenerateHouseholdThumbnail(otherHouse.HouseholdId, otherHouse.HouseholdId, ThumbnailSizeMask.Large | ThumbnailSizeMask.Medium);
                                (Sims3.UI.Responder.Instance.EditTownModel as EditTownModel).DirtyWorldBins();
                                Bin.Singleton.FireContentsChanged();
                            }
                        }

                        Household.CleanupOldIdToNewSimDescriptionMap();
                        if (!flag)
                        {
                            ExportBinContentsEx.Flush(exportBinItem);
                        }
                    }
                    finally
                    {
                        ProgressDialog.Close();
                    }
                }
                catch (ExecutionEngineException)
                { }

                return(householdPresent);
            }
            catch (Exception e)
            {
                Common.Exception("MergeHouseholdFromExportBin", e);
                return(PlaceResult.ContentFailure);
            }
        }