예제 #1
0
파일: TabletEx.cs 프로젝트: yakoder/NRaas
        public static List <Book> GetBooksInTown(Sim actor, bool justFirst, bool noDuplicates, bool autonomous)
        {
            List <Book> list = new List <Book>();

            if (actor != null)
            {
                foreach (Book b in Sims3.Gameplay.Queries.GetObjects <Book>())
                {
                    // Custom
                    if (autonomous)
                    {
                        if (ReadBookData.HasSimFinishedBook(actor, b.Data.ID))
                        {
                            continue;
                        }
                    }

                    if (!justFirst && noDuplicates)
                    {
                        // Fixed Twallan's mistake => he stored the predicate result in a variable outside the loop, so the first "true" value encountered was making it skip all books
                        if (list.Exists((Book toTest) => toTest.BookId == b.BookId))
                        {
                            continue;
                        }
                    }
                    list.Add(b);
                    if (justFirst)
                    {
                        return(list);
                    }
                }
            }
            return(list);
        }
예제 #2
0
        public static Book ChooseBook(Sim actor, List <Book> books)
        {
            if (books.Count == 0x0)
            {
                return(null);
            }

            float       minValue = float.MinValue;
            List <Book> list     = new List <Book>();

            foreach (IGameObject obj in books)
            {
                Book book = obj as Book;
                if (book == null)
                {
                    continue;
                }

                if (ReadBookData.HasSimFinishedBook(actor, book.Data.ID))
                {
                    continue;
                }

                float interestInBook = BookEx.GetInterestInBook(actor, book);
                if (interestInBook == 0f)
                {
                    continue;
                }

                if (interestInBook > minValue)
                {
                    list.Clear();
                    list.Add(book);
                    minValue = interestInBook;
                }
                else if (interestInBook == minValue)
                {
                    list.Add(book);
                }
            }

            if (list.Count == 0x0)
            {
                return(null);
            }

            return(list[RandomUtil.GetInt(list.Count - 0x1)]);
        }
예제 #3
0
            public override bool Test(Sim a, Book target, bool isAutonomous, ref GreyedOutTooltipCallback greyedOutTooltipCallback)
            {
                if (target is SheetMusic)
                {
                    return(false);
                }

                if (isAutonomous)
                {
                    if (ReadBookData.HasSimFinishedBook(a, target.Data.ID))
                    {
                        return(false);
                    }
                }

                return(base.Test(a, target, isAutonomous, ref greyedOutTooltipCallback));
            }
예제 #4
0
            public override void PopulatePieMenuPicker(ref InteractionInstanceParameters parameters, out List <ObjectPicker.TabInfo> listObjs, out List <ObjectPicker.HeaderInfo> headers, out int NumSelectableRows)
            {
                NumSelectableRows = 0x1;

                headers  = null;
                listObjs = null;

                try
                {
                    IGameObject target = parameters.Target;
                    headers  = new List <ObjectPicker.HeaderInfo>();
                    listObjs = new List <ObjectPicker.TabInfo>();
                    headers.Add(new ObjectPicker.HeaderInfo("Ui/Caption/ObjectPicker:Title", "Ui/Tooltip/ObjectPicker:Name", 0xfa));
                    List <ObjectPicker.RowInfo> rowInfo = new List <ObjectPicker.RowInfo>();
                    foreach (BookToddler book in Inventories.QuickDuoFind <BookToddler, Book>(parameters.Target.Inventory))
                    {
                        if (ReadBookData.HasSimFinishedBook(Toddler, book.Data.ID))
                        {
                            continue;
                        }

                        List <ObjectPicker.ColumnInfo> columnInfo = new List <ObjectPicker.ColumnInfo>();
                        ThumbnailKey thumbnail = new ThumbnailKey(new ResourceKey((ulong)ResourceUtils.XorFoldHashString32("book_standard"), 0x1661233, 0x1), ThumbnailSize.Medium, ResourceUtils.HashString32(book.Data.GeometryState), ResourceUtils.HashString32(book.Data.MaterialState));
                        columnInfo.Add(new ObjectPicker.ThumbAndTextColumn(thumbnail, book.Data.Title));
                        ObjectPicker.RowInfo info = new ObjectPicker.RowInfo(book, columnInfo);
                        rowInfo.Add(info);
                    }

                    // Custom code
                    if (rowInfo.Count == 0)
                    {
                        listObjs = null;
                    }
                    else
                    {
                        ObjectPicker.TabInfo item = new ObjectPicker.TabInfo("Coupon", Common.LocalizeEAString("Ui/Caption/ObjectPicker:ToddlerBooks"), rowInfo);
                        listObjs.Add(item);
                    }
                }
                catch (Exception e)
                {
                    Common.Exception(parameters.Actor, parameters.Target, e);
                }
            }
예제 #5
0
            public override void AddInteractions(InteractionObjectPair iop, Sim actor, BookToddler target, List <InteractionObjectPair> results)
            {
                if (Test(actor))
                {
                    foreach (Sim sim in actor.LotCurrent.GetSims())
                    {
                        if (!sim.SimDescription.Toddler)
                        {
                            continue;
                        }

                        if (ReadBookData.HasSimFinishedBook(sim, target.Data.ID))
                        {
                            continue;
                        }

                        results.Add(new InteractionObjectPair(new BookToddler_ReadWithMenu.SubDefinition(sim), target));
                    }
                }
            }
예제 #6
0
            public override void AddInteractions(InteractionObjectPair iop, Sim actor, Bookshelf target, List <InteractionObjectPair> results)
            {
                if (actor.SimDescription.TeenOrAbove && (target.Inventory.AmountIn <BookToddler>() != 0x0))
                {
                    List <Sim> list = new List <Sim>();
                    foreach (Sim sim in actor.LotCurrent.GetSims())
                    {
                        if (sim.SimDescription.Toddler)
                        {
                            bool found = false;
                            foreach (BookToddler book in Inventories.QuickDuoFind <BookToddler, Book>(target.Inventory))
                            {
                                if (!ReadBookData.HasSimFinishedBook(sim, book.Data.ID))
                                {
                                    found = true;
                                }
                            }

                            if (found)
                            {
                                list.Add(sim);
                            }
                        }
                    }
                    if (list.Count != 0x0)
                    {
                        if (list.Count == 0x1)
                        {
                            results.Add(new InteractionObjectPair(new Definition(list[0x0], Bookshelf_ReadToToddler.LocalizeString("ReadWith", new object[] { list[0x0] }), new string[0x0]), target));
                        }
                        else
                        {
                            foreach (Sim sim2 in list)
                            {
                                results.Add(new InteractionObjectPair(new Definition(sim2, sim2.SimDescription.FirstName, new string[] { Common.LocalizeEAString("Gameplay/Objects/BookToddler:ReadWithMenuText") }), target));
                            }
                        }
                    }
                }
            }