private string GetSelectedObjectCodexID() { string text = string.Empty; CellSelectionObject component = SelectTool.Instance.selected.GetComponent <CellSelectionObject>(); BuildingUnderConstruction component2 = SelectTool.Instance.selected.GetComponent <BuildingUnderConstruction>(); CreatureBrain component3 = SelectTool.Instance.selected.GetComponent <CreatureBrain>(); PlantableSeed component4 = SelectTool.Instance.selected.GetComponent <PlantableSeed>(); BudUprootedMonitor component5 = SelectTool.Instance.selected.GetComponent <BudUprootedMonitor>(); if ((UnityEngine.Object)component != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component.element.id.ToString()); } else if ((UnityEngine.Object)component2 != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component2.Def.PrefabID); } else if ((UnityEngine.Object)component3 != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString()); text = text.Replace("BABY", string.Empty); } else if ((UnityEngine.Object)component4 != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString()); text = text.Replace("SEED", string.Empty); } else if ((UnityEngine.Object)component5 != (UnityEngine.Object)null) { if ((UnityEngine.Object)component5.parentObject.Get() != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component5.parentObject.Get().PrefabID().ToString()); } else if ((UnityEngine.Object)component5.GetComponent <TreeBud>() != (UnityEngine.Object)null) { text = CodexCache.FormatLinkID(component5.GetComponent <TreeBud>().buddingTrunk.Get().PrefabID().ToString()); } } else { text = CodexCache.FormatLinkID(SelectTool.Instance.selected.PrefabID().ToString()); } if (CodexCache.entries.ContainsKey(text) || CodexCache.FindSubEntry(text) != null) { return(text); } return(string.Empty); }
public void ChangeArticle(string id, bool playClickSound = false) { Debug.Assert(id != null); if (playClickSound) { KMonoBehaviour.PlaySound(GlobalAssets.GetSound("HUD_Click", false)); } if (contentContainerPool == null) { Init(); } SubEntry subEntry = null; if (!CodexCache.entries.ContainsKey(id)) { subEntry = null; subEntry = CodexCache.FindSubEntry(id); if (subEntry != null && !subEntry.disabled) { id = subEntry.parentEntryID.ToUpper(); } } ICodexWidget codexWidget = null; CodexCache.entries[id].GetFirstWidget(); RectTransform rectTransform = null; if (subEntry != null) { foreach (ContentContainer contentContainer2 in CodexCache.entries[id].contentContainers) { if (contentContainer2 == subEntry.contentContainers[0]) { codexWidget = contentContainer2.content[0]; break; } } } if (!CodexCache.entries.ContainsKey(id) || CodexCache.entries[id].disabled) { id = "PAGENOTFOUND"; } int num = 0; string text = string.Empty; while (contentContainers.transform.childCount > 0) { while (!string.IsNullOrEmpty(text) && CodexCache.entries[activeEntryID].contentContainers[num].lockID == text) { num++; } GameObject gameObject = contentContainers.transform.GetChild(0).gameObject; int num2 = 0; while (gameObject.transform.childCount > 0) { GameObject gameObject2 = gameObject.transform.GetChild(0).gameObject; Type key; if (gameObject2.name == "PrefabContentLocked") { text = CodexCache.entries[activeEntryID].contentContainers[num].lockID; key = typeof(CodexContentLockedIndicator); } else { key = CodexCache.entries[activeEntryID].contentContainers[num].content[num2].GetType(); } ContentUIPools[key].ClearElement(gameObject2); num2++; } contentContainerPool.ClearElement(contentContainers.transform.GetChild(0).gameObject); num++; } bool flag = CodexCache.entries[id] is CategoryEntry; activeEntryID = id; if (CodexCache.entries[id].contentContainers == null) { CodexCache.entries[id].contentContainers = new List <ContentContainer>(); } bool flag2 = false; string a = string.Empty; for (int i = 0; i < CodexCache.entries[id].contentContainers.Count; i++) { ContentContainer contentContainer = CodexCache.entries[id].contentContainers[i]; if (!string.IsNullOrEmpty(contentContainer.lockID) && !Game.Instance.unlocks.IsUnlocked(contentContainer.lockID)) { if (a != contentContainer.lockID) { GameObject gameObject3 = contentContainerPool.GetFreeElement(contentContainers.gameObject, true).gameObject; ConfigureContentContainer(contentContainer, gameObject3, flag && flag2); a = contentContainer.lockID; GameObject gameObject4 = ContentUIPools[typeof(CodexContentLockedIndicator)].GetFreeElement(gameObject3, true).gameObject; } } else { GameObject gameObject3 = contentContainerPool.GetFreeElement(contentContainers.gameObject, true).gameObject; ConfigureContentContainer(contentContainer, gameObject3, flag && flag2); flag2 = !flag2; if (contentContainer.content != null) { foreach (ICodexWidget item in contentContainer.content) { GameObject gameObject5 = ContentUIPools[item.GetType()].GetFreeElement(gameObject3, true).gameObject; item.Configure(gameObject5, displayPane, textStyles); if (item == codexWidget) { rectTransform = gameObject5.rectTransform(); } } } } } string text2 = string.Empty; string text3 = id; int num3 = 0; while (text3 != CodexCache.FormatLinkID("HOME") && num3 < 10) { num3++; if (text3 != null) { text2 = ((!(text3 != id)) ? text2.Insert(0, CodexCache.entries[text3].name) : text2.Insert(0, CodexCache.entries[text3].name + " > ")); text3 = CodexCache.entries[text3].parentId; } else { text3 = CodexCache.entries[CodexCache.FormatLinkID("HOME")].id; text2 = text2.Insert(0, CodexCache.entries[text3].name + " > "); } } currentLocationText.text = ((!(text2 == string.Empty)) ? text2 : CodexCache.entries["HOME"].name); if (history.Count == 0) { history.Add(activeEntryID); } else if (history[history.Count - 1] != activeEntryID) { if (history.Count > 1 && history[history.Count - 2] == activeEntryID) { history.RemoveAt(history.Count - 1); } else { history.Add(activeEntryID); } } if (history.Count > 1) { backButton.text = UI.FormatAsLink(string.Format(UI.CODEX.BACK_BUTTON, UI.StripLinkFormatting(CodexCache.entries[history[history.Count - 2]].name)), CodexCache.entries[history[history.Count - 2]].id); } else { backButton.text = UI.StripLinkFormatting(GameUtil.ColourizeString(Color.grey, string.Format(UI.CODEX.BACK_BUTTON, CodexCache.entries["HOME"].name))); } if ((UnityEngine.Object)rectTransform != (UnityEngine.Object)null) { if (scrollToTargetRoutine != null) { StopCoroutine(scrollToTargetRoutine); } scrollToTargetRoutine = StartCoroutine(ScrollToTarget(rectTransform)); } else { displayScrollRect.content.SetLocalPosition(Vector3.zero); } }