// Token: 0x06000F1E RID: 3870 RVA: 0x0006BF5C File Offset: 0x0006A15C private void ShowDreamText() { DreamTexts.DreamText randomDreamText = this.m_dreamTexts.GetRandomDreamText(); if (randomDreamText == null) { return; } this.m_dreamField.enabled = true; this.m_dreamField.canvasRenderer.SetAlpha(0f); this.m_dreamField.CrossFadeAlpha(1f, 1.5f, true); this.m_dreamField.text = Localization.instance.Localize(randomDreamText.m_text); base.Invoke("HideDreamText", 6.5f); }
// Token: 0x06000CF0 RID: 3312 RVA: 0x0005C9B4 File Offset: 0x0005ABB4 private bool HaveGlobalKeys(DreamTexts.DreamText dream) { foreach (string name in dream.m_trueKeys) { if (!ZoneSystem.instance.GetGlobalKey(name)) { return(false); } } foreach (string name2 in dream.m_falseKeys) { if (ZoneSystem.instance.GetGlobalKey(name2)) { return(false); } } return(true); }
// Token: 0x06000CEF RID: 3311 RVA: 0x0005C924 File Offset: 0x0005AB24 public DreamTexts.DreamText GetRandomDreamText() { List <DreamTexts.DreamText> list = new List <DreamTexts.DreamText>(); foreach (DreamTexts.DreamText dreamText in this.m_texts) { if (this.HaveGlobalKeys(dreamText)) { list.Add(dreamText); } } if (list.Count == 0) { return(null); } DreamTexts.DreamText dreamText2 = list[UnityEngine.Random.Range(0, list.Count)]; if (UnityEngine.Random.value <= dreamText2.m_chanceToDream) { return(dreamText2); } return(null); }
private static void LoadDreams() { if (!Hud.instance) { return; } string path = Path.Combine(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location), "CustomDreamTexts"); if (!Directory.Exists(path)) { Dbgl($"Directory {path} does not exist! Creating."); Directory.CreateDirectory(path); } string defaultFolder = Path.Combine(path, "Default"); SleepText sleepText = Hud.instance.m_sleepingProgress.GetComponent <SleepText>(); DreamTexts dreamTexts = sleepText.m_dreamTexts; if (!Directory.Exists(defaultFolder)) { Dbgl($"Directory {defaultFolder} does not exist! Creating."); Directory.CreateDirectory(defaultFolder); List <string> localizedDreams = new List <string>(); for (int i = 0; i < dreamTexts.m_texts.Count; i++) { DreamTexts.DreamText dt = dreamTexts.m_texts[i]; localizedDreams.Add(dt.m_text + ": " + Localization.instance.Localize(dt.m_text)); string json = JsonUtility.ToJson(dt); File.WriteAllText(Path.Combine(defaultFolder, (i + 1) + ".json"), json); } File.WriteAllLines(Path.Combine(defaultFolder, "localized.txt"), localizedDreams); } var files = Directory.GetFiles(path, "*.txt"); foreach (string file in files) { string name = Path.GetFileNameWithoutExtension(file); string folder = Path.Combine(path, name); if (Directory.Exists(folder)) { continue; } Directory.CreateDirectory(folder); string[] lines = File.ReadAllLines(file); for (int i = 0; i < lines.Length; i++) { string[] parts = lines[i].Split('|'); string text; if (parts[0].Contains("^")) { string[] quoteAuthor = parts[0].Split('^'); text = quoteAuthor[0] + quoteAuthorSeparator.Value + quoteAuthor[1]; } else { text = parts[0]; } float chance = parts.Length > 1 && parts[1].Length > 0 ? float.Parse(parts[1]) : defaultChance.Value; DreamTexts.DreamText dt = new DreamTexts.DreamText() { m_chanceToDream = chance, m_text = text }; string json = JsonUtility.ToJson(dt); File.WriteAllText(Path.Combine(folder, (i + 1) + ".json"), json); } } if (currentDreamFolder.Value != "Default") { string dreamFolder = Path.Combine(path, currentDreamFolder.Value); if (!Directory.Exists(dreamFolder)) { Dbgl("Dream folder does not exist!"); return; } sleepText.m_dreamTexts.m_texts.Clear(); int count = 1; string thisDream = Path.Combine(dreamFolder, (count++) + ".json"); while (File.Exists(thisDream)) { string dream = File.ReadAllText(thisDream); sleepText.m_dreamTexts.m_texts.Add(JsonUtility.FromJson <DreamTexts.DreamText>(dream)); thisDream = Path.Combine(dreamFolder, (count++) + ".json"); } Dbgl($"Loaded {sleepText.m_dreamTexts.m_texts.Count} dreams"); } }