Example #1
0
        public static void CreateSimInventories(List <SimDescription> sims, HouseholdContents contents, List <ulong> indexMap)
        {
            List <Sim> newborns = new List <Sim>();

            for (int i = 0x0; i < sims.Count; i++)
            {
                SimDescription description = sims[i];

                // Custom Try/Catch
                try
                {
                    if ((description != null) && (description.CreatedSim != null))
                    {
                        int index = i;
                        if (indexMap != null)
                        {
                            for (int j = 0x0; j < indexMap.Count; j++)
                            {
                                if (indexMap[j] == description.SimDescriptionId)
                                {
                                    index = j;
                                    break;
                                }
                            }
                        }
                        ulong id = contents.Inventories[index];
                        if (id != 0x0L)
                        {
                            Diploma diploma = description.CreatedSim.Inventory.Find <Diploma>();
                            if ((diploma != null) && !description.CreatedSim.Inventory.TryToRemove(diploma))
                            {
                                diploma = null;
                            }

                            IPhoneSmart smart = null;
                            if (GameUtils.IsInstalled(ProductVersion.EP9))
                            {
                                smart = description.CreatedSim.Inventory.Find <IPhoneSmart>();
                                if ((smart != null) && !description.CreatedSim.Inventory.TryToRemove(smart))
                                {
                                    smart = null;
                                }
                            }

                            DownloadContent.ImportInventory(id, new InventoryProxy(description.CreatedSim.Inventory));
                            DownloadContent.DeleteInventory(id);

                            if (diploma != null)
                            {
                                Inventories.TryToMove(diploma, description.CreatedSim.Inventory, false);
                            }

                            if (smart != null)
                            {
                                IPhoneCell cell = description.CreatedSim.Inventory.Find <IPhoneCell>();
                                if (cell != null)
                                {
                                    cell.Destroy();
                                }
                                description.CreatedSim.Inventory.TryToAdd(smart);
                            }
                        }
                        else
                        {
                            if (description.Toddler)
                            {
                                newborns.Add(description.CreatedSim);
                            }
                            description.CreatedSim.AddInitialObjects(false);
                        }
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(description, e);
                }
            }

            // Custom Try/Catch
            try
            {
                OccultImaginaryFriend.DeliverDollToHousehold(newborns, true);
            }
            catch (Exception e)
            {
                Common.Exception("DeliverDollToHousehold", e);
            }
        }