Пример #1
0
        public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
        {
            UIElement uiElement = new UIElement()
            {
                Width  = new StyleDimension(0.0f, 1f),
                Height = new StyleDimension(112f, 0.0f)
            };

            uiElement.SetPadding(0.0f);
            BestiaryEntry     entry = new BestiaryEntry();
            Asset <Texture2D> portraitBackgroundAsset = (Asset <Texture2D>)null;
            Color             white = Color.White;

            entry.Icon           = info.OwnerEntry.Icon.CreateClone();
            entry.UIInfoProvider = info.OwnerEntry.UIInfoProvider;
            List <IBestiaryBackgroundOverlayAndColorProvider> overlays = new List <IBestiaryBackgroundOverlayAndColorProvider>();
            bool flag1 = info.UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0;

            if (flag1)
            {
                List <IBestiaryInfoElement> source1 = new List <IBestiaryInfoElement>();
                IEnumerable <IBestiaryBackgroundImagePathAndColorProvider> source2 = info.OwnerEntry.Info.OfType <IBestiaryBackgroundImagePathAndColorProvider>();
                IEnumerable <IPreferenceProviderElement> preferences = info.OwnerEntry.Info.OfType <IPreferenceProviderElement>();
                Func <IBestiaryBackgroundImagePathAndColorProvider, bool>  predicate         = (Func <IBestiaryBackgroundImagePathAndColorProvider, bool>)(provider => preferences.Any <IPreferenceProviderElement>((Func <IPreferenceProviderElement, bool>)(preference => preference.Matches(provider))));
                IEnumerable <IBestiaryBackgroundImagePathAndColorProvider> andColorProviders = source2.Where <IBestiaryBackgroundImagePathAndColorProvider>(predicate);
                bool flag2 = false;
                foreach (IBestiaryBackgroundImagePathAndColorProvider andColorProvider in andColorProviders)
                {
                    Asset <Texture2D> backgroundImage = andColorProvider.GetBackgroundImage();
                    if (backgroundImage != null)
                    {
                        portraitBackgroundAsset = backgroundImage;
                        flag2 = true;
                        Color?backgroundColor = andColorProvider.GetBackgroundColor();
                        if (backgroundColor.HasValue)
                        {
                            white = backgroundColor.Value;
                            break;
                        }
                        break;
                    }
                }
                foreach (IBestiaryInfoElement bestiaryInfoElement in info.OwnerEntry.Info)
                {
                    if (bestiaryInfoElement is IBestiaryBackgroundImagePathAndColorProvider andColorProvider)
                    {
                        Asset <Texture2D> backgroundImage = andColorProvider.GetBackgroundImage();
                        if (backgroundImage != null)
                        {
                            if (!flag2)
                            {
                                portraitBackgroundAsset = backgroundImage;
                            }
                            Color?backgroundColor = andColorProvider.GetBackgroundColor();
                            if (backgroundColor.HasValue)
                            {
                                white = backgroundColor.Value;
                            }
                        }
                        else
                        {
                            continue;
                        }
                    }
                    if (!flag2 && bestiaryInfoElement is IBestiaryBackgroundOverlayAndColorProvider andColorProvider2 && andColorProvider2.GetBackgroundOverlayImage() != null)
                    {
                        source1.Add(bestiaryInfoElement);
                    }
                }
                overlays.AddRange(source1.OrderBy <IBestiaryInfoElement, float>(new Func <IBestiaryInfoElement, float>(this.GetSortingValueForElement)).Select <IBestiaryInfoElement, IBestiaryBackgroundOverlayAndColorProvider>((Func <IBestiaryInfoElement, IBestiaryBackgroundOverlayAndColorProvider>)(x => x as IBestiaryBackgroundOverlayAndColorProvider)));
            }
            UIBestiaryNPCEntryPortrait npcEntryPortrait1 = new UIBestiaryNPCEntryPortrait(entry, portraitBackgroundAsset, white, overlays);

            npcEntryPortrait1.Left   = new StyleDimension(4f, 0.0f);
            npcEntryPortrait1.HAlign = 0.0f;
            UIBestiaryNPCEntryPortrait npcEntryPortrait2 = npcEntryPortrait1;

            uiElement.Append((UIElement)npcEntryPortrait2);
            if (flag1 && this._filledStarsCount.HasValue)
            {
                UIElement starsContainer = this.CreateStarsContainer();
                uiElement.Append(starsContainer);
            }
            return(uiElement);
        }
        public UIElement ProvideUIElement(BestiaryUICollectionInfo info)
        {
            UIElement uIElement = new UIElement
            {
                Width  = new StyleDimension(0f, 1f),
                Height = new StyleDimension(112f, 0f)
            };

            uIElement.SetPadding(0f);
            BestiaryEntry     bestiaryEntry           = new BestiaryEntry();
            Asset <Texture2D> portraitBackgroundAsset = null;
            Color             portraitColor           = Color.White;

            bestiaryEntry.Icon           = info.OwnerEntry.Icon.CreateClone();
            bestiaryEntry.UIInfoProvider = info.OwnerEntry.UIInfoProvider;
            List <IBestiaryBackgroundOverlayAndColorProvider> list = new List <IBestiaryBackgroundOverlayAndColorProvider>();
            bool flag = info.UnlockState > BestiaryEntryUnlockState.NotKnownAtAll_0;

            if (flag)
            {
                List <IBestiaryInfoElement> list2 = new List <IBestiaryInfoElement>();
                IEnumerable <IBestiaryBackgroundImagePathAndColorProvider> source = info.OwnerEntry.Info.OfType <IBestiaryBackgroundImagePathAndColorProvider>();
                IEnumerable <IPreferenceProviderElement> preferences = info.OwnerEntry.Info.OfType <IPreferenceProviderElement>();
                IEnumerable <IBestiaryBackgroundImagePathAndColorProvider> enumerable = source.Where((IBestiaryBackgroundImagePathAndColorProvider provider) => preferences.Any((IPreferenceProviderElement preference) => preference.Matches(provider)));
                bool flag2 = false;
                foreach (IBestiaryBackgroundImagePathAndColorProvider item in enumerable)
                {
                    Asset <Texture2D> backgroundImage = item.GetBackgroundImage();
                    if (backgroundImage != null)
                    {
                        portraitBackgroundAsset = backgroundImage;
                        flag2 = true;
                        Color?backgroundColor = item.GetBackgroundColor();
                        if (backgroundColor.HasValue)
                        {
                            portraitColor = backgroundColor.Value;
                        }
                        break;
                    }
                }
                foreach (IBestiaryInfoElement item2 in info.OwnerEntry.Info)
                {
                    IBestiaryBackgroundImagePathAndColorProvider bestiaryBackgroundImagePathAndColorProvider = item2 as IBestiaryBackgroundImagePathAndColorProvider;
                    if (bestiaryBackgroundImagePathAndColorProvider != null)
                    {
                        Asset <Texture2D> backgroundImage2 = bestiaryBackgroundImagePathAndColorProvider.GetBackgroundImage();
                        if (backgroundImage2 == null)
                        {
                            continue;
                        }
                        if (!flag2)
                        {
                            portraitBackgroundAsset = backgroundImage2;
                        }
                        Color?backgroundColor2 = bestiaryBackgroundImagePathAndColorProvider.GetBackgroundColor();
                        if (backgroundColor2.HasValue)
                        {
                            portraitColor = backgroundColor2.Value;
                        }
                    }
                    if (!flag2)
                    {
                        IBestiaryBackgroundOverlayAndColorProvider bestiaryBackgroundOverlayAndColorProvider = item2 as IBestiaryBackgroundOverlayAndColorProvider;
                        if (bestiaryBackgroundOverlayAndColorProvider != null && bestiaryBackgroundOverlayAndColorProvider.GetBackgroundOverlayImage() != null)
                        {
                            list2.Add(item2);
                        }
                    }
                }
                list.AddRange(from x in list2.OrderBy(GetSortingValueForElement)
                              select x as IBestiaryBackgroundOverlayAndColorProvider);
            }
            UIBestiaryNPCEntryPortrait element = new UIBestiaryNPCEntryPortrait(bestiaryEntry, portraitBackgroundAsset, portraitColor, list)
            {
                Left   = new StyleDimension(4f, 0f),
                HAlign = 0f
            };

            uIElement.Append(element);
            if (flag && _filledStarsCount.HasValue)
            {
                UIElement element2 = CreateStarsContainer();
                uIElement.Append(element2);
            }
            return(uIElement);
        }