Elin Decompiled Documentation EA 23.287 Stable Patch 3
Loading...
Searching...
No Matches
Msg.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3
4public class Msg : EClass
5{
7
9
11
12 public static bool alwaysVisible;
13
14 public static bool ignoreAll;
15
17
19
21
22 public static void SetColor()
23 {
25 }
26
27 public static void SetColor(Color color)
28 {
29 currentColor = color;
30 }
31
32 public static void SetColor(string id)
33 {
35 }
36
37 public static string GetRawText(string idLang, string ref1, string ref2 = null, string ref3 = null, string ref4 = null)
38 {
39 thirdPerson1.Set(ref1);
40 thirdPerson2.Set(ref2);
41 return GameLang.Parse(GetGameText(idLang), IsThirdPerson(ref1), ref1, ref2, ref3, ref4);
42 }
43
44 public static string GetRawText(string idLang, Card c1, Card c2, string ref1 = null, string ref2 = null)
45 {
46 thirdPerson1.Set(c1);
47 thirdPerson2.Set(c2);
48 return GameLang.Parse(GetGameText(idLang), IsThirdPerson(c1), GetName(c1), GetName(c2), ref1, ref2);
49 }
50
51 public static string GetRawText(string idLang, Card c1, string ref1 = null, string ref2 = null, string ref3 = null)
52 {
53 thirdPerson1.Set(c1);
54 thirdPerson2.Set(ref1);
55 return GameLang.Parse(GetGameText(idLang), IsThirdPerson(c1), GetName(c1), ref1, ref2, ref3);
56 }
57
58 public static string Say(string idLang, string ref1, string ref2 = null, string ref3 = null, string ref4 = null)
59 {
60 thirdPerson1.Set(ref1);
61 thirdPerson2.Set(ref2);
62 return SayRaw(GameLang.Parse(GetGameText(idLang), IsThirdPerson(ref1), ref1, ref2, ref3, ref4));
63 }
64
65 public static string Say(string idLang, Card c1, Card c2, string ref1 = null, string ref2 = null)
66 {
67 thirdPerson1.Set(c1);
68 thirdPerson2.Set(c2);
69 return SayRaw(GameLang.Parse(GetGameText(idLang), IsThirdPerson(c1), GetName(c1), GetName(c2), ref1, ref2));
70 }
71
72 public static string Say(string idLang, Card c1, string ref1 = null, string ref2 = null, string ref3 = null)
73 {
74 thirdPerson1.Set(c1);
75 thirdPerson2.Set(ref1);
76 return SayRaw(GameLang.Parse(GetGameText(idLang), IsThirdPerson(c1), GetName(c1), ref1, ref2, ref3));
77 }
78
79 public static string Say(string idLang, Card c1, int i, string ref1 = null)
80 {
81 thirdPerson1.Set(c1);
82 thirdPerson2.Set(ref1);
83 return SayRaw(GameLang.Parse(GetGameText(idLang), IsThirdPerson(i), GetName(c1), i.ToString() ?? "", ref1));
84 }
85
86 public static string Say(string idLang, int i, string ref1 = null, string ref2 = null)
87 {
88 return SayRaw(GameLang.Parse(GetGameText(idLang), IsThirdPerson(i), ref1, ref2));
89 }
90
91 public static string Say(string idLang)
92 {
93 return SayRaw(GetGameText(idLang));
94 }
95
96 public static string SayNothingHappen()
97 {
98 return Say("nothingHappens");
99 }
100
101 public static string SayCannotUseHere()
102 {
103 return Say("cannot_use_here");
104 }
105
106 public static string SayInvalidAction()
107 {
108 return Say("invalidAction");
109 }
110
111 public static void SayGod(string s, Card owner = null)
112 {
114 Say(s.Bracket());
115 owner?.SayRaw("@1" + s);
116 }
117
118 public static string SayRaw(string text)
119 {
120 if (ignoreAll)
121 {
123 return "";
124 }
125 ToUpperFirst(text);
126 if ((bool)feed)
127 {
128 feed.System(text);
129 }
130 if ((bool)mainText)
131 {
133 }
135 alwaysVisible = false;
136 EClass.game.log.Add(text);
137 return text;
138 }
139
140 public static void Append(Sprite sprite)
141 {
142 mainText.Append(sprite);
143 }
144
145 public static void AquireItem(string itemName)
146 {
147 Say("getItem", itemName ?? "");
148 }
149
150 public static void Nerun(string lang, string idPortrait = "UN_nerun")
151 {
152 string text = GameLang.Convert(lang.lang());
153 if ((bool)feed)
154 {
155 feed.Nerun(text, idPortrait);
156 }
157 else if ((bool)mainText)
158 {
159 mainText.Append(text.Bracket(1), colors.Talk);
160 }
161 }
162
163 public static void SayHomeMember(string lang)
164 {
165 string text = GameLang.Convert(lang.lang());
166 if ((bool)feed)
167 {
168 feed.Nerun(text);
169 }
170 else if ((bool)mainText)
171 {
172 mainText.Append(text.Bracket(1), colors.Talk);
173 }
174 }
175
176 public static void SayPic(Card c, string lang)
177 {
178 if (c != null)
179 {
180 string text = GameLang.Convert(lang.lang());
181 if ((bool)feed)
182 {
183 feed.SayRaw(c, text);
184 }
185 else if ((bool)mainText)
186 {
187 mainText.Append(text.Bracket(1), colors.Talk);
188 }
189 }
190 }
191
192 public static void SayPic(string idPortrait, string lang, string _idPop = null)
193 {
194 string text = GameLang.Convert(lang.lang());
195 if ((bool)feed)
196 {
197 feed.SayRaw(idPortrait, text, _idPop);
198 }
199 else if ((bool)mainText)
200 {
201 mainText.Append(text.Bracket(1), colors.Talk);
202 }
203 }
204
205 public static PopItem Talk(Card c, string id)
206 {
207 PopItem result = null;
208 if (c == null)
209 {
210 return null;
211 }
212 string text = GameLang.Convert(c.GetTalkText(id, stripPun: true));
213 if ((bool)feed && c != null)
214 {
215 result = feed.SayRaw(c, text);
216 }
217 else if ((bool)mainText)
218 {
219 mainText.Append(text.Bracket(1), colors.Talk);
220 }
221 return result;
222 }
223
224 public static PopItem TalkHomeMemeber(string id)
225 {
226 Chara chara = null;
227 if (EClass.Branch != null)
228 {
229 for (int i = 0; i < 99; i++)
230 {
231 chara = EClass.Branch.members.RandomItem();
232 if (chara != EClass.pc)
233 {
234 break;
235 }
236 }
237 }
238 if (chara == null)
239 {
240 chara = EClass.pc;
241 }
242 return Talk(chara, id);
243 }
244
245 public static PopItem TalkMaid(string id)
246 {
247 foreach (Chara chara in EClass._map.charas)
248 {
249 if (chara.uid == EClass.Branch?.uidMaid)
250 {
251 return Talk(chara, id);
252 }
253 }
254 return TalkHomeMemeber(id);
255 }
256
257 public static string GetGameText(string idLang, Card card = null)
258 {
259 LangGame.Row row = EClass.core.sources.langGame.map.TryGetValue(idLang);
260 if (row == null)
261 {
262 return idLang.lang();
263 }
264 if (!row.effect.IsEmpty() && row.effect == "destroy")
265 {
267 }
268 if (!row.color.IsEmpty() && colors.colors.TryGetValue(row.color, out var value))
269 {
270 SetColor(value);
271 }
272 if (!row.sound.IsEmpty())
273 {
274 EClass.Sound.Play(row.sound);
275 }
276 return row.GetText("text").Split(Environment.NewLine.ToCharArray()).RandomItem();
277 }
278
279 public static string GetName(Card c)
280 {
281 if (c == null)
282 {
283 return "null";
284 }
285 if (c.IsPC)
286 {
287 return "you".lang();
288 }
289 if (!alwaysVisible && (EClass.pc.isBlind || !EClass.pc.CanSee(c)) && c.parent == EClass._zone)
290 {
291 return (c.isChara ? "someone" : "something").lang();
292 }
293 return c.Name;
294 }
295
296 public static bool IsThirdPerson(Card c)
297 {
298 if (c == null)
299 {
300 return false;
301 }
302 if (c.IsPC || c.Num > 1)
303 {
304 return false;
305 }
306 return true;
307 }
308
309 public static bool IsThirdPerson(string n)
310 {
311 if (!int.TryParse(n, out var result))
312 {
313 return false;
314 }
315 return IsThirdPerson(result);
316 }
317
318 public static bool IsThirdPerson(int i)
319 {
320 return i <= 1;
321 }
322
323 public static void NewLine()
324 {
325 if ((bool)mainText)
326 {
328 }
329 }
330
331 public unsafe static void ToUpperFirst(string str)
332 {
333 if (str != null)
334 {
335 fixed (char* ptr = str)
336 {
337 *ptr = char.ToUpper(*ptr);
338 }
339 }
340 }
341}
Definition: Card.cs:11
string Name
Definition: Card.cs:2177
ICardParent parent
Definition: Card.cs:56
string GetTalkText(string idTopic, bool stripPun=false, bool useDefault=true)
Definition: Card.cs:7079
int uid
Definition: Card.cs:123
virtual bool IsPC
Definition: Card.cs:2183
virtual bool isChara
Definition: Card.cs:2121
int Num
Definition: Card.cs:159
Definition: Chara.cs:10
bool CanSee(Card c)
Definition: Chara.cs:1244
bool isBlind
Definition: Chara.cs:132
MsgColors msgColors
Definition: CoreRef.cs:409
CoreRef refs
Definition: Core.cs:51
SourceManager sources
Definition: Core.cs:33
Definition: EClass.cs:6
static Game game
Definition: EClass.cs:9
static Core core
Definition: EClass.cs:7
static Zone _zone
Definition: EClass.cs:21
static Map _map
Definition: EClass.cs:19
static FactionBranch Branch
Definition: EClass.cs:23
static Chara pc
Definition: EClass.cs:15
static SoundManager Sound
Definition: EClass.cs:47
List< Chara > members
static string Convert(string text)
Definition: GameLang.cs:161
static string Parse(string text, bool thirdPerson, string val1, string val2=null, string val3=null, string val4=null)
Definition: GameLang.cs:178
MsgLog log
Definition: Game.cs:189
string sound
Definition: LangGame.cs:16
string color
Definition: LangGame.cs:12
string effect
Definition: LangGame.cs:18
List< Chara > charas
Definition: Map.cs:81
UD_String_Color colors
Definition: MsgColors.cs:23
Color Talk
Definition: MsgColors.cs:7
Color Default
Definition: MsgColors.cs:5
Color TalkGod
Definition: MsgColors.cs:9
void Add(Data data)
Definition: MsgLog.cs:53
Definition: Msg.cs:5
static bool IsThirdPerson(Card c)
Definition: Msg.cs:296
static string Say(string idLang, int i, string ref1=null, string ref2=null)
Definition: Msg.cs:86
static bool IsThirdPerson(int i)
Definition: Msg.cs:318
static string Say(string idLang)
Definition: Msg.cs:91
static string GetGameText(string idLang, Card card=null)
Definition: Msg.cs:257
static PopItem TalkHomeMemeber(string id)
Definition: Msg.cs:224
static void NewLine()
Definition: Msg.cs:323
static void SayGod(string s, Card owner=null)
Definition: Msg.cs:111
static void AquireItem(string itemName)
Definition: Msg.cs:145
static WidgetFeed feed
Definition: Msg.cs:18
static PopItem Talk(Card c, string id)
Definition: Msg.cs:205
static string GetRawText(string idLang, Card c1, string ref1=null, string ref2=null, string ref3=null)
Definition: Msg.cs:51
static void Append(Sprite sprite)
Definition: Msg.cs:140
static Color currentColor
Definition: Msg.cs:10
static bool alwaysVisible
Definition: Msg.cs:12
static void SayHomeMember(string lang)
Definition: Msg.cs:163
static string Say(string idLang, Card c1, string ref1=null, string ref2=null, string ref3=null)
Definition: Msg.cs:72
static PopItem TalkMaid(string id)
Definition: Msg.cs:245
static bool ignoreAll
Definition: Msg.cs:14
static MsgColors colors
Definition: Msg.cs:20
static ThirstPersonInfo thirdPerson2
Definition: Msg.cs:8
static string GetRawText(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:37
static unsafe void ToUpperFirst(string str)
Definition: Msg.cs:331
static string GetRawText(string idLang, Card c1, Card c2, string ref1=null, string ref2=null)
Definition: Msg.cs:44
static void SetColor(string id)
Definition: Msg.cs:32
static void SayPic(Card c, string lang)
Definition: Msg.cs:176
static string Say(string idLang, Card c1, Card c2, string ref1=null, string ref2=null)
Definition: Msg.cs:65
static string SayRaw(string text)
Definition: Msg.cs:118
static void SayPic(string idPortrait, string lang, string _idPop=null)
Definition: Msg.cs:192
static bool IsThirdPerson(string n)
Definition: Msg.cs:309
static string SayInvalidAction()
Definition: Msg.cs:106
static string SayCannotUseHere()
Definition: Msg.cs:101
static WidgetMainText mainText
Definition: Msg.cs:16
static ThirstPersonInfo thirdPerson1
Definition: Msg.cs:6
static void SetColor(Color color)
Definition: Msg.cs:27
static void Nerun(string lang, string idPortrait="UN_nerun")
Definition: Msg.cs:150
static string Say(string idLang, Card c1, int i, string ref1=null)
Definition: Msg.cs:79
static string SayNothingHappen()
Definition: Msg.cs:96
static string GetName(Card c)
Definition: Msg.cs:279
static string Say(string idLang, string ref1, string ref2=null, string ref3=null, string ref4=null)
Definition: Msg.cs:58
static void SetColor()
Definition: Msg.cs:22
string GetText(string id="name", bool returnNull=false)
Definition: SourceData.cs:626
LangGame langGame
void Set(string n)
bool TryGetValue(TKey key, out TValue value)
Definition: UDictionary.cs:178
void System(string text)
Definition: WidgetFeed.cs:98
PopItem SayRaw(Card c, string text)
Definition: WidgetFeed.cs:81
void Nerun(string text, string idPortrait="UN_nerun")
Definition: WidgetFeed.cs:93
static WidgetFeed Instance
Definition: WidgetFeed.cs:14
static WidgetMainText Instance
void Append(string s, Point pos=null)
Sprite spriteDestroy