Ejemplo n.º 1
0
        public static PlaceResult PlaceHouseholdFromGameBin(ulong contentId, Lot lot, PlaceAction action, GetLotCost onLotCost)
        {
            HouseholdContents contents = Bin.Singleton.FindHousehold(contentId);

            if (contents != null)
            {
                Household household = contents.Household;
                if (household != null)
                {
                    if (((action & PlaceAction.PlaceAndPay) != PlaceAction.PlaceOnly) && !PayForLot(household, lot, true, onLotCost))
                    {
                        return(PlaceResult.InsufficientFunds);
                    }
                    BinCommonEx.CreateActors(household, lot, false);
                    BinCommonEx.CreateInventories(contents);
                    if ((action & PlaceAction.MoveIn) != PlaceAction.PlaceOnly)
                    {
                        BinCommon.MoveIn(household, lot);
                    }
                    Bin.Singleton.RemoveHouseholdFromGameBin(contents);
                    return(PlaceResult.Success);
                }
            }
            return(PlaceResult.ContentFailure);
        }
Ejemplo n.º 2
0
        public static void CreateInventories(Household household, HouseholdContents contents, List <ulong> indexMap)
        {
            if ((contents != null) && (household != null))
            {
                // Custom Function
                CreateSimInventories(household.AllSimDescriptions, contents, indexMap);

                // Custom Try/Catch
                try
                {
                    BinCommon.CreateFamilyInventories(household, contents);
                }
                catch (Exception e)
                {
                    Common.Exception("CreateFamilyInventories", e);
                }
            }
        }
Ejemplo n.º 3
0
        public static bool HouseholdContents_ExportContent(HouseholdContents This, ResKeyTable resKeyTable, ObjectIdTable objIdTable, IPropertyStreamWriter writer)
        {
            if (This == null)
            {
                throw new NullReferenceException();
            }
            IPropertyStreamWriter writer2 = writer.CreateChild(2221750924u);

            try
            {
                if (This.mHousehold == null || !Household_ExportContent(This.mHousehold, resKeyTable, objIdTable, writer2))
                {
                    return(false);
                }
            }
            catch (StackOverflowException) { throw; }
            catch (ResetException)
            {
                throw;
            }
            catch { }

            writer.CommitChild();
            writer.WriteInt32(1758660904u, This.mInventories.Length);
            int[] array = new int[This.mInventories.Length];
            int   num   = 0;

            ulong[] array2 = This.mInventories;
            foreach (ulong num2 in array2)
            {
                uint        type   = (uint)((num2 != 0) ? (-1260555925) : 0);
                ResourceKey newKey = new ResourceKey(num2, type, 0u);
                array[num++] = resKeyTable.AddKey(newKey);
            }
            writer.WriteInt32(2746246615u, array);
            return(true);
        }
Ejemplo n.º 4
0
 public HouseholdContentsProxy(Household household)
 {
     mContents = new HouseholdContents(household);
 }
Ejemplo n.º 5
0
 public HouseholdContentsProxy()
 {
     mContents = new HouseholdContents();
 }
Ejemplo n.º 6
0
        public static Household _ImportHousehold(string packageFile, Lot moveinLot, bool full, bool askToCreateSim, out HouseholdContents contents)
        {
            contents = null;
            if (packageFile == null || packageFile.Length == 0)
            {
                return(null);
            }

            try
            {
                HouseholdContentsProxy hoc = HouseholdContentsProxy.Import(packageFile);
                if (hoc != null)
                {
                    Household mhouse = hoc.Household;
                    if (mhouse != null && mhouse.mMembers != null && mhouse.AllSimDescriptions != null && mhouse.AllSimDescriptions.Count != 0)
                    {
                        foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray())
                        {
                            item.mHousehold = mhouse;
                        }

                        try
                        {
                            mhouse.FixupGenealogy();
                        }
                        catch (Exception)
                        { }

                        foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray())
                        {
                            try
                            {
                                item.Fixup();
                            }
                            catch (Exception)
                            { }
                        }



                        bool donelotofmovein = false;
                        if (moveinLot != null && moveinLot.mHousehold == null)
                        {
                            donelotofmovein = true;
                            try
                            {
                                moveinLot.MoveIn(mhouse);
                            }
                            catch (Exception)
                            {
                                moveinLot.mHousehold = mhouse;
                                mhouse.mLotId        = moveinLot.mLotId;
                                mhouse.mLotHome      = moveinLot;
                            }
                        }
                        if (!full)
                        {
                            full = askToCreateSim && Simulator.CheckYieldingContext(false) && NiecMod.Nra.NFinalizeDeath.CheckAccept("Create Sim?");
                        }
                        if (full)
                        {
                            //Sim sim = null;
                            if (donelotofmovein)
                            {
                                try
                                {
                                    foreach (SimDescription item in mhouse.AllSimDescriptions.ToArray())
                                    {
                                        try
                                        {
                                            if (NiecMod.Nra.NFinalizeDeath.SimDesc_OutfitsIsValid(item))
                                            {
                                                item.Instantiate(Service.GetPositionInRandomLot(moveinLot), false);
                                            }
                                        }
                                        catch (Exception)
                                        { }
                                    }
                                }
                                catch (Exception)
                                { }
                            }
                            try
                            {
                                BinCommon.CreateInventories(mhouse, hoc.Contents, NiecMod.Nra.NFinalizeDeath.CreateIndexMap_(mhouse));
                            }
                            catch (Exception)
                            { }
                        }
                        contents = hoc.Contents;
                        return(mhouse);
                    }
                    else
                    {
                        if (mhouse != null)
                        {
                            mhouse.Destroy();
                        }

                        NiecMod.Nra.NiecException.PrintMessagePro("Check mhouse is invalid.\nSorry :(", false, 100);
                    }
                }
                else
                {
                    NiecMod.Nra.NiecException.PrintMessagePro("Could not find Package File" + "\n" + packageFile, false, 1000);
                }
            }
            catch (Exception)
            { }
            return(null);
        }
Ejemplo n.º 7
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);
            }
        }
Ejemplo n.º 8
0
 public static void CreateInventories(HouseholdContents contents)
 {
     CreateInventories(contents.Household, contents, null);
 }
Ejemplo n.º 9
0
 public HouseholdContentsProxy(Household household)
 {
     mContents = new HouseholdContents(household);
 }
Ejemplo n.º 10
0
 public HouseholdContentsProxy()
 {
     mContents = new HouseholdContents();
 }