private void CreatePartIcons(PartData data, float xPos, Transform parent, List <GameObject> newButtons) { for (int i = 0; i < this.PartTierCount - 1; i++) { for (int j = 0; j < data.RowWidth(); j++) { int index = j; Vector3 localPosition = new Vector3(xPos + (float)index * this.horizontalPadding, (float)(this.PartTierCount / 2) - (float)i * this.verticalPadding + this.verticalPadding); localPosition.y += ((i != 0) ? 0f : this.firstRowPadding); BasePart.PartTier tier = (BasePart.PartTier)i; bool flag; if (tier == BasePart.PartTier.Epic) { flag = (index < data.PartCount(tier) || data.PartCount(BasePart.PartTier.Legendary) > 0); if (index >= data.PartCount(tier)) { index -= data.PartCount(tier); tier = BasePart.PartTier.Legendary; } } else { flag = (index < data.PartCount(tier)); } if (!this.columns.Contains(localPosition.x)) { this.columns.Add(localPosition.x); } if (flag) { GameObject bg = UnityEngine.Object.Instantiate <GameObject>(this.GetIconBackground(tier)); bg.transform.parent = parent; bg.transform.localPosition = localPosition; Sprite icon2 = data.GetIcon(tier, index); GameObject icon = null; if (icon2 != null) { icon = UnityEngine.Object.Instantiate <GameObject>(icon2.gameObject); icon.transform.parent = bg.transform; icon.transform.localPosition = new Vector3(0f, 0f, -0.1f); icon.transform.localScale = Vector3.one * this.iconScale; } if (tier != BasePart.PartTier.Regular) { this.ToGray(bg, !CustomizationManager.IsPartUnlocked(data.parts[tier][index])); } if (this.IsKingsFavorite(data.parts[tier][index])) { GameObject gameObject; this.AddKingsFavoriteTag(bg, out gameObject); } GameObject item; if (CustomizationManager.IsPartNew(data.parts[tier][index]) && this.AddNewContentTag(bg, out item)) { newButtons.Add(item); } data.AddPartRoot(tier, bg); Button button = bg.GetComponentInChildren <Button>(); GameObjectEvents gameObjectEvents = bg.AddComponent <GameObjectEvents>(); GameObjectEvents gameObjectEvents2 = gameObjectEvents; gameObjectEvents2.OnEnabled = (Action <bool>) Delegate.Combine(gameObjectEvents2.OnEnabled, new Action <bool>(delegate(bool enabled) { if (enabled) { if (this.IsKingsFavorite(data.parts[tier][index])) { GameObject gameObject2; this.AddKingsFavoriteTag(bg, out gameObject2); } else { this.ClearKingsFavoriteTag(bg); } if (tier != BasePart.PartTier.Regular) { bool flag2 = CustomizationManager.IsPartUnlocked(data.parts[tier][index]); this.ToGray(bg, !flag2); Collider component = bg.GetComponent <Collider>(); component.enabled = flag2; button.enabled = flag2; if (tier == BasePart.PartTier.Legendary) { if (icon) { icon.SetActive(flag2); } bg.transform.Find("QuestionMark").gameObject.SetActive(!flag2); } int lastUsedPartIndex = CustomizationManager.GetLastUsedPartIndex(data.PartType); data.UpdateSelectionIcon(this.gameData.GetCustomPart(data.PartType, lastUsedPartIndex).name); if (CustomizationManager.IsPartNew(data.parts[tier][index])) { GameObject item2; if (this.AddNewContentTag(bg, out item2)) { newButtons.Add(item2); } } else { this.ClearNewTags(bg); } } } })); GameObjectEvents gameObjectEvents3 = gameObjectEvents; gameObjectEvents3.OnVisible = (Action <bool>) Delegate.Combine(gameObjectEvents3.OnVisible, new Action <bool>(delegate(bool visible) { button.enabled = visible; })); this.SetSortingLayer(bg, this.sortingLayer); } } } }