////////////////

        public bool IsBookEnabled(string bookName)
        {
            if (!this.Books.ContainsKey(bookName))
            {
                throw new ModHelpersException("No such book by name " + bookName);
            }

            InventoryBook book = this.Books[bookName];

            return(book.IsEnabled);
        }
コード例 #2
0
        public bool RemoveLatestBookPage(Player player, string bookName, out string err)
        {
            if (!this.Books.ContainsKey(bookName))
            {
                throw new ModHelpersException("No such book by name " + bookName);
            }

            InventoryBook book = this.Books[bookName];

            return(book.DeleteEmptyPage(player, book.CountPages() - 1, out err));
        }
コード例 #3
0
        public void DisableBook(string bookName)
        {
            if (!this.Books.ContainsKey(bookName))
            {
                throw new ModHelpersException("No such book by name " + bookName);
            }

            InventoryBook book = this.Books[bookName];

            book.IsEnabled = false;
        }
コード例 #4
0
        ////////////////

        public Item[] GetBookPageItems(Player player, string bookName, int pageIdx)
        {
            if (!this.Books.ContainsKey(bookName))
            {
                throw new ModHelpersException("No such book by name " + bookName);
            }

            InventoryBook book = this.Books[bookName];

            return(book.GetPageItems(player, pageIdx));
        }
        ////////////////

        public Item[] GetLatestBookPageItems(Player player, string bookName)
        {
            if (this.Books.ContainsKey(bookName))
            {
                throw new ModHelpersException("No such book by name " + bookName);
            }

            InventoryBook book  = this.Books[bookName];
            int           count = book.CountPages();

            if (count == 0)
            {
                return(null);
            }

            return(book.GetPageItems(player, count - 1));
        }
コード例 #6
0
        internal void Load(TagCompound tags)
        {
            var mymod = ExtensibleInventoryMod.Instance;

            if (!tags.ContainsKey("book_count") || !tags.ContainsKey("curr_book"))
            {
                var book = new InventoryBook(mymod.Config.DefaultBookEnabled, InventoryLibrary.DefaultBookName);

                book.Load(InventoryLibrary.DefaultBookName.ToLower(), tags);
                this.Books[InventoryLibrary.DefaultBookName] = book;

                return;
            }

            this.Books.Clear();

            int    bookCount    = tags.GetInt("book_count");
            string currBookName = tags.GetString("curr_book");

            for (int i = 0; i < bookCount; i++)
            {
                string bookName   = tags.GetString("book_name_" + i);
                string bookNameIo = bookName.ToLower();

                bool isEnabled = false;
                if (bookName == InventoryLibrary.DefaultBookName)
                {
                    isEnabled = mymod.Config.DefaultBookEnabled;
                }

                var book = new InventoryBook(isEnabled, bookName);

                book.Load(bookNameIo, tags);

                this.Books[bookName] = book;
            }

            this.CurrBookName = currBookName;
        }
コード例 #7
0
        internal TagCompound Save(TagCompound tags)
        {
            tags["book_count"] = this.Books.Count;
            tags["curr_book"]  = this.CurrBookName;

            int i = 0;

            foreach (var kv in this.Books)
            {
                string bookName   = kv.Key;
                string bookNameIo = bookName.ToLower();

                InventoryBook book = kv.Value;

                tags["book_name_" + i] = bookName;
                book.Save(bookNameIo, tags);

                i++;
            }

            return(tags);
        }