private FollowerListItem InsertFollowerIntoListView(WrapperGarrisonFollower follower) { GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID); if (record == null) { return(null); } if (record.GarrFollowerTypeID != (uint)GarrisonStatus.GarrisonFollowerType) { return(null); } if (this.m_isCombatAllyList) { bool flags = (follower.Flags & 8) != 0; FollowerStatus followerStatus = GeneralHelpers.GetFollowerStatus(follower); if (flags || follower.ZoneSupportSpellID <= 0 || followerStatus == FollowerStatus.inactive || followerStatus == FollowerStatus.fatigued || followerStatus == FollowerStatus.inBuilding) { return(null); } } GameObject gameObject = UnityEngine.Object.Instantiate <GameObject>(this.m_followerListItemPrefab); gameObject.transform.SetParent(this.m_followerListViewContents.transform, false); FollowerListItem component = gameObject.GetComponent <FollowerListItem>(); component.SetFollower(follower); return(component); }
public void InitFollowerList() { FollowerListItem[] componentsInChildren = this.m_followerListViewContents.GetComponentsInChildren <FollowerListItem>(true); FollowerListItem[] followerListItemArray = componentsInChildren; for (int i = 0; i < (int)followerListItemArray.Length; i++) { FollowerListItem followerListItem = followerListItemArray[i]; if (PersistentFollowerData.followerDictionary.ContainsKey(followerListItem.m_followerID)) { WrapperGarrisonFollower item = PersistentFollowerData.followerDictionary[followerListItem.m_followerID]; if ((item.Flags & 8) == 0 || item.Durability > 0) { followerListItem.SetFollower(item); } else { followerListItem.gameObject.SetActive(false); followerListItem.transform.SetParent(Main.instance.transform); } } else { followerListItem.gameObject.SetActive(false); followerListItem.transform.SetParent(Main.instance.transform); } } Transform mFollowerListViewContents = this.m_followerListViewContents.transform; float single = this.m_followerListViewContents.transform.localPosition.x; Vector3 vector3 = this.m_followerListViewContents.transform.localPosition; mFollowerListViewContents.localPosition = new Vector3(single, 0f, vector3.z); this.SortFollowerListData(); componentsInChildren = this.m_followerListViewContents.GetComponentsInChildren <FollowerListItem>(true); foreach (KeyValuePair <int, WrapperGarrisonFollower> mSortedFollowerList in this.m_sortedFollowerList) { bool flag = false; FollowerListItem[] followerListItemArray1 = componentsInChildren; int num = 0; while (num < (int)followerListItemArray1.Length) { if (followerListItemArray1[num].m_followerID != mSortedFollowerList.Value.GarrFollowerID) { num++; } else { flag = true; break; } } if (!flag) { if ((mSortedFollowerList.Value.Flags & 8) == 0 || mSortedFollowerList.Value.Durability > 0) { this.InsertFollowerIntoListView(mSortedFollowerList.Value); } } } }
private void InsertFollowerIntoListView(WrapperGarrisonFollower follower, FollowerCategory followerCategory) { GarrFollowerRec record = StaticDB.garrFollowerDB.GetRecord(follower.GarrFollowerID); if (record == null) { return; } if (record.GarrFollowerTypeID != (uint)GarrisonStatus.GarrisonFollowerType) { return; } bool flags = (follower.Flags & 8) != 0; bool flag = !flags; FollowerStatus followerStatus = GeneralHelpers.GetFollowerStatus(follower); switch (followerCategory) { case FollowerCategory.ActiveChampion: { if (!flag || followerStatus == FollowerStatus.inactive) { return; } break; } case FollowerCategory.InactiveChampion: { if (!flag || followerStatus != FollowerStatus.inactive) { return; } break; } case FollowerCategory.Troop: { if (!flags || follower.Durability <= 0) { return; } break; } default: { return; } } FollowerListItem followerListItem = UnityEngine.Object.Instantiate <FollowerListItem>(this.m_followerDetailListItemPrefab); followerListItem.transform.SetParent(this.m_followerDetailListContent.transform, false); followerListItem.SetFollower(follower); }
private void InitFollowerList() { FollowerListItem[] componentsInChildren = this.m_followerDetailListContent.GetComponentsInChildren <FollowerListItem>(true); FollowerListItem[] followerListItemArray = componentsInChildren; for (int i = 0; i < (int)followerListItemArray.Length; i++) { FollowerListItem followerListItem = followerListItemArray[i]; if (PersistentFollowerData.followerDictionary.ContainsKey(followerListItem.m_followerID)) { WrapperGarrisonFollower item = PersistentFollowerData.followerDictionary[followerListItem.m_followerID]; if ((item.Flags & 8) == 0 || item.Durability > 0) { followerListItem.SetFollower(item); } else { UnityEngine.Object.Destroy(followerListItem.gameObject); followerListItem.transform.SetParent(null); } } else { UnityEngine.Object.Destroy(followerListItem.gameObject); followerListItem.transform.SetParent(null); } } this.SortFollowerListData(); foreach (KeyValuePair <int, WrapperGarrisonFollower> mSortedFollowerList in this.m_sortedFollowerList) { bool flag = false; FollowerListItem[] followerListItemArray1 = componentsInChildren; int num = 0; while (num < (int)followerListItemArray1.Length) { if (followerListItemArray1[num].m_followerID != mSortedFollowerList.Value.GarrFollowerID) { num++; } else { flag = true; break; } } if (!flag) { this.InsertFollowerIntoListView(mSortedFollowerList.Value, FollowerCategory.ActiveChampion); } } foreach (KeyValuePair <int, WrapperGarrisonFollower> keyValuePair in this.m_sortedFollowerList) { bool flag1 = false; FollowerListItem[] followerListItemArray2 = componentsInChildren; int num1 = 0; while (num1 < (int)followerListItemArray2.Length) { if (followerListItemArray2[num1].m_followerID != keyValuePair.Value.GarrFollowerID) { num1++; } else { flag1 = true; break; } } if (!flag1) { this.InsertFollowerIntoListView(keyValuePair.Value, FollowerCategory.Troop); } } foreach (KeyValuePair <int, WrapperGarrisonFollower> mSortedFollowerList1 in this.m_sortedFollowerList) { bool flag2 = false; FollowerListItem[] followerListItemArray3 = componentsInChildren; int num2 = 0; while (num2 < (int)followerListItemArray3.Length) { if (followerListItemArray3[num2].m_followerID != mSortedFollowerList1.Value.GarrFollowerID) { num2++; } else { flag2 = true; break; } } if (!flag2) { this.InsertFollowerIntoListView(mSortedFollowerList1.Value, FollowerCategory.InactiveChampion); } } this.SyncVisibleListOrderToSortedFollowerList(); }