Beispiel #1
0
        public static IGameObject ChooseBook(Sim actor, List <IGameObject> 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;
                }

                ReadBookData data;
                if (actor.ReadBookDataList.TryGetValue(book.Data.ID, out data))
                {
                    if (data.TimesRead > 0)
                    {
                        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)]);
        }
Beispiel #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)]);
        }
Beispiel #3
0
            public float CalculateScore(InteractionObjectPair interactionObjectPair, Sims3.Gameplay.Autonomy.Autonomy autonomy)
            {
                float num = 0f;

                mAutonomyBook = null;
                foreach (Book book in TabletEx.GetBooksInTown(autonomy.Actor, false, true, true))
                //foreach (Book book in Tablet.GetBooksOnMyLot(autonomy.Actor, false, true))
                {
                    // Custom
                    ReadBookData data;
                    if (autonomy.Actor.ReadBookDataList.TryGetValue(book.Data.ID, out data))
                    {
                        if (data.TimesRead > 0)
                        {
                            continue;
                        }
                    }

                    GreyedOutTooltipCallback greyedOutTooltipCallback = null;
                    if (book.TestReadBook(autonomy.Actor, true, ref greyedOutTooltipCallback))
                    {
                        float interestInBook = BookEx.GetInterestInBook(autonomy.Actor, book);
                        if (interestInBook > num)
                        {
                            mAutonomyBook = book;
                            num           = interestInBook;
                        }
                    }
                }

                if (mAutonomyBook == null)
                {
                    return(0f);
                }

                if (autonomy.Actor.HasTrait(TraitNames.ComputerWhiz))
                {
                    num *= Tablet.kCompWhizMultiplier;
                }
                else if (autonomy.Actor.HasTrait(TraitNames.AntiTV))
                {
                    num *= Tablet.kTechnophobeMultiplier;
                }

                return(num * autonomy.CalculateScoreForObjectInteraction(interactionObjectPair));
            }