Elin Decompiled Documentation EA 23.130 Nightly
Loading...
Searching...
No Matches
TalkDataList.cs
Go to the documentation of this file.
1using System;
2using System.Collections.Generic;
3using UnityEngine;
4
6{
7 public List<string> IDs;
8
9 public override int StartIndex => 2;
10
11 public override void OnInitialize()
12 {
13 IDs = new List<string>();
14 foreach (string key in list[0].Keys)
15 {
16 if (key != "id" && key != "path")
17 {
18 IDs.Add(key);
19 }
20 }
21 }
22
23 public string GetTalk(string id, string idTopic, bool useDefault = false, bool human = true)
24 {
25 if (!initialized)
26 {
27 Initialize();
28 }
29 bool flag = false;
30 Dictionary<string, string> dictionary = all.TryGetValue(idTopic);
31 if (dictionary == null)
32 {
33 return "";
34 }
35 string text = dictionary.TryGetValue(id);
36 if (text.IsEmpty())
37 {
38 if (!useDefault)
39 {
40 Debug.LogError("id not found:" + id);
41 return "";
42 }
43 text = dictionary.TryGetValue("default");
44 flag = true;
45 }
46 text = text.Split(new string[3] { "\r\n", "\r", "\n" }, StringSplitOptions.None).RandomItem();
47 if (!human)
48 {
49 if (flag && !text.IsEmpty() && !text.StartsWith("(") && !text.StartsWith("*"))
50 {
51 text = "(" + text + ")";
52 }
53 text = text.Replace("。)", ")");
54 }
55 return text;
56 }
57
58 public string GetRandomID(string tag)
59 {
60 return IDs.RandomItem();
61 }
62}
Dictionary< string, Dictionary< string, string > > all
Definition: ExcelDataList.cs:8
List< Dictionary< string, string > > list
virtual void Initialize()
override void OnInitialize()
Definition: TalkDataList.cs:11
string GetTalk(string id, string idTopic, bool useDefault=false, bool human=true)
Definition: TalkDataList.cs:23
List< string > IDs
Definition: TalkDataList.cs:7
string GetRandomID(string tag)
Definition: TalkDataList.cs:58
override int StartIndex
Definition: TalkDataList.cs:9