Elin Modding Docs Doc
Loading...
Searching...
No Matches
NewsList.cs
1using System;
2using System.Collections.Generic;
3using System.IO;
4using System.Runtime.CompilerServices;
5
6// Token: 0x020005A5 RID: 1445
7public class NewsList : EClass
8{
9 // Token: 0x060027A5 RID: 10149 RVA: 0x000E072D File Offset: 0x000DE92D
10 public static void Init()
11 {
12 if (NewsList.dict != null)
13 {
14 return;
15 }
16 NewsList.dict = new Dictionary<string, List<NewsList.Item>>();
17 NewsList.listAll.Clear();
18 NewsList.<Init>g__AddDir|3_0(CorePath.CorePackage.News);
19 }
20
21 // Token: 0x060027A6 RID: 10150 RVA: 0x000E0758 File Offset: 0x000DE958
22 public static List<NewsList.Item> GetNews(int seed)
23 {
24 NewsList.Init();
25 Rand.SetSeed(seed);
26 List<NewsList.Item> list = new List<NewsList.Item>();
27 for (int i = 0; i < 1000; i++)
28 {
29 NewsList.Item item = NewsList.listAll.RandomItem<NewsList.Item>();
30 if (!list.Contains(item))
31 {
32 list.Add(item);
33 if (list.Count >= 3)
34 {
35 break;
36 }
37 }
38 }
39 Rand.SetSeed(-1);
40 return list;
41 }
42
43 // Token: 0x060027A9 RID: 10153 RVA: 0x000E07C8 File Offset: 0x000DE9C8
44 [CompilerGenerated]
45 internal static void <Init>g__AddDir|3_0(string path)
46 {
47 DirectoryInfo directoryInfo = new DirectoryInfo(path);
48 NewsList.Item item = null;
49 foreach (FileInfo fileInfo in directoryInfo.GetFiles())
50 {
51 if (!(fileInfo.Extension != ".txt"))
52 {
53 string fileNameWithoutExtension = Path.GetFileNameWithoutExtension(fileInfo.Name);
54 List<NewsList.Item> list = NewsList.dict.TryGetValue(fileNameWithoutExtension, null);
55 StreamReader streamReader = new StreamReader(fileInfo.FullName);
56 string text = null;
57 while (!streamReader.EndOfStream)
58 {
59 string text2 = streamReader.ReadLine();
60 if (!string.IsNullOrEmpty(text2))
61 {
62 if (text2.StartsWith('@') && item != null)
63 {
64 foreach (string item2 in text2.TrimStart('@').Split(',', StringSplitOptions.None))
65 {
66 item.listImageId.Add(item2);
67 }
68 }
69 else if (text == null)
70 {
71 text = text2;
72 }
73 else
74 {
75 item = new NewsList.Item
76 {
77 title = text,
78 content = text2
79 };
80 if (list == null)
81 {
82 list = new List<NewsList.Item>();
83 NewsList.dict.Add(fileNameWithoutExtension, list);
84 }
85 list.Add(item);
86 NewsList.listAll.Add(item);
87 text = null;
88 }
89 }
90 }
91 }
92 }
93 }
94
95 // Token: 0x04001614 RID: 5652
96 public static Dictionary<string, List<NewsList.Item>> dict;
97
98 // Token: 0x04001615 RID: 5653
99 public static List<NewsList.Item> listAll = new List<NewsList.Item>();
100
101 // Token: 0x02000AF5 RID: 2805
102 public class Item : EClass
103 {
104 // Token: 0x04002C69 RID: 11369
105 public string title;
106
107 // Token: 0x04002C6A RID: 11370
108 public string content;
109
110 // Token: 0x04002C6B RID: 11371
111 public List<string> listImageId = new List<string>();
112 }
113}