Пример #1
0
        public static bool ChangeLotType(ulong lotId, bool deleteInvalidObjects, LotType newType, CommercialLotSubType commercialSubType, ResidentialLotSubType residentialSubType)
        {
            EditTownModel ths = EditTownController.Instance.mModel as EditTownModel;

            Lot lot = LotManager.GetLot(lotId);

            if (lot == null)
            {
                return(false);
            }
            if (newType == LotType.Residential)
            {
                commercialSubType = CommercialLotSubType.kCommercialUndefined;
            }
            else
            {
                residentialSubType = ResidentialLotSubType.kResidentialUndefined;
            }

            if ((newType != LotType.Residential) && (commercialSubType == CommercialLotSubType.kCommercialUndefined))
            {
                return(false);
            }

            if (!ChangeLotTypeHelper(lot, deleteInvalidObjects, newType, commercialSubType, residentialSubType))
            {
                return(false);
            }

            ths.GetInWorldCommunityLotBinInfoList();
            ths.GetInWorldLotBinInfoList();
            lot.LotType = newType;
            lot.CommercialLotSubType  = commercialSubType;
            lot.ResidentialLotSubType = residentialSubType;
            if (lot.IsCommunityLot)
            {
                UIBinInfo item  = ths.FindLotBinInfo(lotId);
                bool      flag2 = true;
                if (item == null)
                {
                    flag2 = false;
                    item  = ths.FindCommunityLotBinInfo(lotId);
                }
                if (item != null)
                {
                    item.LotTypeFilter         = 0x8;
                    item.LotType               = newType;
                    item.CommercialLotSubType  = commercialSubType;
                    item.ResidentialLotSubType = residentialSubType;
                    if (flag2)
                    {
                        ths.mInWorldLotBin.Remove(item);
                        ths.mInWorldCommunityLotBin.Add(item);
                    }
                }
            }
            else
            {
                UIBinInfo info2 = ths.FindCommunityLotBinInfo(lotId);
                bool      flag3 = true;
                if (info2 == null)
                {
                    flag3 = false;
                    info2 = ths.FindLotBinInfo(lotId);
                }
                if (info2 != null)
                {
                    if (World.LotIsEmpty(lotId) && lot.IsLotEmptyFromObjects())
                    {
                        info2.LotTypeFilter = 0x2;
                    }
                    else
                    {
                        info2.LotTypeFilter = 0x4;
                    }
                    info2.LotType = newType;
                    info2.CommercialLotSubType  = commercialSubType;
                    info2.ResidentialLotSubType = residentialSubType;
                    if (flag3)
                    {
                        ths.mInWorldCommunityLotBin.Remove(info2);
                        ths.mInWorldLotBin.Add(info2);
                    }
                }
            }

            SpeedTrap.Sleep();
            lot.EnsureLotObjects();

            try
            {
                Sims3.Gameplay.Services.Services.ClearServicesForLot(lot);
            }
            catch (Exception e)
            {
                Common.Exception(lot, e);
            }

            Occupation.ValidateJobConsistencyWithLotType(lot);
            lot.UpdateCachedValues();
            return(true);
        }