Elin Decompiled Documentation EA 23.102 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 Debug.LogError("idTopic not found:" + idTopic);
34 return "";
35 }
36 string text = dictionary.TryGetValue(id);
37 if (text.IsEmpty())
38 {
39 if (!useDefault)
40 {
41 Debug.LogError("id not found:" + id);
42 return "";
43 }
44 text = dictionary.TryGetValue("default");
45 flag = true;
46 }
47 text = text.Split(new string[3] { "\r\n", "\r", "\n" }, StringSplitOptions.None).RandomItem();
48 if (!human)
49 {
50 if (flag && !text.IsEmpty() && !text.StartsWith("(") && !text.StartsWith("*"))
51 {
52 text = "(" + text + ")";
53 }
54 text = text.Replace("。)", ")");
55 }
56 return text;
57 }
58
59 public string GetRandomID(string tag)
60 {
61 return IDs.RandomItem();
62 }
63}
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:59
override int StartIndex
Definition: TalkDataList.cs:9