Ejemplo n.º 1
0
        public static PlaceResult PlaceFromGameBin(EditTownModel ths, UIBinInfo info, ulong lotId, PlaceAction action)
        {
            PlaceResult contentFailure = PlaceResult.ContentFailure;
            Lot         lot            = LotManager.GetLot(lotId);

            if (lot == null)
            {
                return(PlaceResult.InvalidLot);
            }
            else if (lot.Household != null)
            {
                return(PlaceResult.HouseholdPresent);
            }

            ths.GetInWorldHouseholdBinInfoList();
            contentFailure = PlaceResult.ContentFailure;
            if (info.HouseholdId != ulong.MaxValue)
            {
                BinCommon.KickSimsOffLot(lot, true);
                if (info.LotId != ulong.MaxValue)
                {
                    contentFailure = BinCommonEx.PlaceHouseholdAndContentsFromGameBin(info.ContentId, lot, action, Mover.GetLotCost);
                }
                else
                {
                    contentFailure = BinCommonEx.PlaceHouseholdFromGameBin(info.ContentId, lot, action, Mover.GetLotCost);
                }

                if (contentFailure != PlaceResult.Success)
                {
                    return(contentFailure);
                }

                ths.mGameBin.Remove(info);
                if (ths.GameBinChanged != null)
                {
                    ths.GameBinChanged(ths, null);
                }

                info = BinCommon.CreateInWorldBinInfo(lot.Household, lot);
                if (info != null)
                {
                    ths.mInWorldHouseholdBin.Add(info);
                }
            }
            return(contentFailure);
        }
Ejemplo n.º 2
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);
            }
        }
Ejemplo n.º 3
0
        private static bool ChangeLotTypeHelper(Lot lot, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType)
        {
            List <GameObject> objects = null;

            if (newType == LotType.Commercial)
            {
                // Custom
                //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidCommunityLotObject));

                if (commercialSubType == CommercialLotSubType.kEP10_Resort)
                {
                    foreach (RabbitHole hole in lot.GetObjects <RabbitHole>(new Predicate <RabbitHole>(EditTownModel.IsInvestable)))
                    {
                        objects.Add(hole);
                    }

                    if (lot.ResortManager == null)
                    {
                        lot.ResortManager = new ResortManager(lot);
                    }
                }
            }
            else
            {
                // Custom
                //objects = lot.GetObjects<GameObject>(new Predicate<GameObject>(EditTownModel.IsNotValidResidentialLotObject));
            }

            if ((objects != null) && (objects.Count > 0))
            {
                if (!deleteInvalidObjects)
                {
                    return(false);
                }

                foreach (GameObject obj2 in objects)
                {
                    int  num  = 0;
                    bool flag = false;
                    while (obj2.ActorsUsingMe.Count > num)
                    {
                        Sim sim = obj2.ActorsUsingMe[num];
                        if (sim != null)
                        {
                            sim.SetObjectToReset();
                            sim.InteractionQueue.PurgeInteractions(obj2);
                            flag = true;
                        }
                        num++;
                    }
                    if (flag)
                    {
                        SpeedTrap.Sleep(0);
                    }
                    lot.RemoveObjectFromLot(obj2.ObjectId, true);
                    obj2.Destroy();
                }

                ThumbnailKey key = new ThumbnailKey(new ResourceKey(lot.LotId, 0x436fee4c, 0), ThumbnailSize.Large);
                ThumbnailManager.InvalidateThumbnail(key);
                EditTownModel.UpdateDirtyLotThumbnailsTask(true);
            }

            if (lot.CommercialLotSubType == CommercialLotSubType.kEP10_Resort)
            {
                foreach (IResortBuffetTable table in lot.GetObjects <IResortBuffetTable>())
                {
                    table.ClearTable();
                }
            }

            if (GameStates.IsEditTownState)
            {
                BinCommon.KickSimsOffLot(lot, true);
            }

            return(true);
        }