Exemple #1
0
    public static void RequestSendBookshelf(ulong BookshelfID, bool IsNewbookBookshelf, GameObject WhoBy)
    {
        if (Librarian.IDToBookShelf.ContainsKey(BookshelfID))
        {
            Librarian.BookShelf Bookshelf = Librarian.IDToBookShelf[BookshelfID];
            if (IsNewbookBookshelf)
            {
                if (!Bookshelf.ICustomBookshelf && Bookshelf.Shelf == null)
                {
                    Logger.LogError("Bookshelf has been destroyed > " + BookshelfID, Category.VariableViewer);
                    return;
                }

                if (Bookshelf.IsPartiallyGenerated)
                {
                    Bookshelf.PopulateBookShelf();
                }

                if (Bookshelf.ObscuredBy != null)
                {
                    SendBookShelfToClient(Bookshelf.ObscuredBy, WhoBy);
                }
            }
            else
            {
                SubBookshelfNetMessage.Send(Bookshelf);
            }
        }
        else
        {
            Logger.LogError("Bookshelf ID has not been generated BookshelfID > " + BookshelfID,
                            Category.VariableViewer);
        }
    }
    public static NetFriendlyBookShelf ProcessSUBBookShelf(Librarian.BookShelf _BookShelf)
    {
        if (_BookShelf.IsPartiallyGenerated)
        {
            _BookShelf.PopulateBookShelf();
        }

        NetFriendlyBookShelf BookShelf = new NetFriendlyBookShelf
        {
            ID = _BookShelf.ID,
            SN = _BookShelf.ShelfName,
            IE = _BookShelf.IsEnabled,
        };
        List <IDnName> lisofIDnName = new List <IDnName>();

        foreach (var ObscuredBookShelve in _BookShelf.ObscuredBookShelves)
        {
            IDnName _IDnName = new IDnName
            {
                ID = ObscuredBookShelve.ID,
                SN = ObscuredBookShelve.ShelfName
            };
            if (_IDnName.SN == null)
            {
                _IDnName.SN = "null";
            }
            lisofIDnName.Add(_IDnName);
        }
        BookShelf.OBS = lisofIDnName.ToArray();
        List <IDnName> _lisofIDnName = new List <IDnName>();

        foreach (var HeldBook in _BookShelf.HeldBooks)
        {
            IDnName _IDnName = new IDnName
            {
                ID = HeldBook.ID,
                SN = HeldBook.BookClass.GetType().Name
            };
            if (_IDnName.SN == null)
            {
                _IDnName.SN = "null";
            }
            _lisofIDnName.Add(_IDnName);
        }


        BookShelf.HB = _lisofIDnName.ToArray();


        BookShelf.OB = new IDnName
        {
            ID = _BookShelf.ObscuredBy.ID,
            SN = _BookShelf.ObscuredBy.ShelfName,
        };
        return(BookShelf);
    }
    public static NetFriendlyBookShelfView ProcessBookShelf(Librarian.BookShelf _BookShelf)
    {
        NetFriendlyBookShelfView TopBookShelf = new NetFriendlyBookShelfView
        {
            ID = _BookShelf.ID
        };
        List <IDnName> NetFriendlyBookShelfs = new List <IDnName>();

        if (_BookShelf.IsPartiallyGenerated)
        {
            _BookShelf.PopulateBookShelf();
        }
        foreach (var ObscuredBookShelve in _BookShelf.ObscuredBookShelves)
        {
            NetFriendlyBookShelfs.Add(ProcessBookShelfToID(ObscuredBookShelve));
        }
        TopBookShelf.HeldShelfIDs = NetFriendlyBookShelfs.ToArray();

        return(TopBookShelf);
    }