Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private static void OnColorsSaved(Color[] colors)
        {
            try
            {
                CASMakeup ths = CASMakeup.gSingleton;
                if (ths == null)
                {
                    return;
                }

                bool flag  = false;
                bool flag2 = false;
                if (CASMakeup.sCategory != BodyTypes.CostumeMakeup)
                {
                    foreach (ItemGridCellItem item in ths.mGridMakeupPresets.Items)
                    {
                        flag2 = true;
                        ResourceKey mTag = (ResourceKey)item.mTag;
                        ColorInfo   info = ColorInfo.FromResourceKey(mTag);
                        for (int i = 0x0; i < info.Colors.Length; i++)
                        {
                            Vector3 vector = CompositorUtil.ColorToVector3(colors[i]);
                            Vector3 v      = CompositorUtil.ColorToVector3(info.Colors[i]);
                            if (!vector.IsSimilarTo(v))
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        ColorInfo info2 = new ColorInfo();
                        info2.Usage = ColorInfo.PreferredUse.Makeup;
                        switch (CASMakeup.sCategory)
                        {
                        case BodyTypes.FirstFace:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupLipstick;
                            break;

                        case BodyTypes.EyeShadow:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupEyeshadow;
                            break;

                        case BodyTypes.EyeLiner:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupEyeliner;
                            break;

                        case BodyTypes.Blush:
                            info2.UsageSubCategory = ColorInfo.eUsageSubCategory.MakeupBlush;
                            break;
                        }
                        info2.Colors = colors;
                        flag         = info2.SaveMakeupPreset(info2.UsageSubCategory) != ResourceKey.kInvalidResourceKey;
                        ths.PopulatePresetsGrid(CASMakeup.sCategory, ths.mCurrentPreset.mPart, ths.mButtonFilter.Selected);
                    }
                }
                else
                {
                    CASPart wornPart = ths.mCurrentPreset.mPart;

                    ObjectDesigner.SetCASPart(wornPart.Key);
                    Vector3[] makeupVectorColors = ths.GetMakeupVectorColors(wornPart);
                    uint      num = CASUtils.PartDataNumPresets(wornPart.Key);
                    for (uint j = 0x0; j < num; j++)
                    {
                        KeyValuePair <string, Dictionary <string, Complate> > presetEntryFromPresetString = (KeyValuePair <string, Dictionary <string, Complate> >)SimBuilder.GetPresetEntryFromPresetString(CASUtils.PartDataGetPreset(wornPart.Key, j));
                        Vector3[] vectorArray2 = ths.GetMakeupVectorColors(presetEntryFromPresetString);
                        flag2 = true;
                        for (uint k = 0x0; k < vectorArray2.Length; k++)
                        {
                            if (!makeupVectorColors[k].IsSimilarTo(vectorArray2[k]))
                            {
                                flag2 = false;
                                break;
                            }
                        }
                        if (flag2)
                        {
                            break;
                        }
                    }

                    if (!flag2)
                    {
                        uint index = ObjectDesigner.AddDesignPreset(Responder.Instance.CASModel.GetDesignPreset(wornPart));
                        flag = index != uint.MaxValue;
                        CASClothingRow row = ths.FindRow(wornPart);
                        if (row != null)
                        {
                            row.CreateGridItems(true);
                            row.PopulateGrid(true);
                        }
                        ths.mButtonCostumeFilter.Tag = true;
                        ths.mContentTypeFilter.UpdateFilterButtonState();
                        ThumbnailKey key = new ThumbnailKey(wornPart.Key, (int)CASUtils.PartDataGetPresetId(wornPart.Key, index), (uint)wornPart.BodyType, (uint)wornPart.AgeGenderSpecies, ThumbnailSize.Large);
                        ThumbnailManager.InvalidateThumbnail(key);
                    }
                }

                if (flag)
                {
                    CASController.Singleton.ErrorMsg(CASErrorCode.SaveSuccess);
                }
                else if (flag2)
                {
                    Simulator.AddObject(new OneShotFunctionTask(delegate
                    {
                        string messageText = Responder.Instance.LocalizationModel.LocalizeString("Ui/Caption/CAS/Hair:SaveDuplicate", new object[0x0]);
                        SimpleMessageDialog.Show(null, messageText, ModalDialog.PauseMode.PauseTask, new Vector2(-1f, -1f), "ui_error", "ui_hardwindow_close");
                    }));
                }
                else
                {
                    CASController.Singleton.ErrorMsg(CASErrorCode.SaveFailed);
                }
            }
            catch (Exception e)
            {
                Common.Exception("OnColorsSaved", e);
            }
        }