public BestiaryPortraitBackgroundBasedOnWorldEvilProviderPreferenceInfoElement( IBestiaryBackgroundImagePathAndColorProvider preferredProviderCorrupt, IBestiaryBackgroundImagePathAndColorProvider preferredProviderCrimson) { this._preferredProviderCorrupt = preferredProviderCorrupt; this._preferredProviderCrimson = preferredProviderCrimson; }
public bool Matches(IBestiaryBackgroundImagePathAndColorProvider provider) { if (Main.ActiveWorldFileData == null || !WorldGen.crimson) { return(provider == _preferredProviderCorrupt); } return(provider == _preferredProviderCrimson); }
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); }
public bool Matches( IBestiaryBackgroundImagePathAndColorProvider provider) { return(provider == this._preferredProvider); }
public BestiaryPortraitBackgroundProviderPreferenceInfoElement( IBestiaryBackgroundImagePathAndColorProvider preferredProvider) { this._preferredProvider = preferredProvider; }