예제 #1
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);
        }
예제 #2
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);
        }
예제 #3
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));
            }
        }
예제 #4
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);
        }
예제 #5
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);
            }
        }