Elin Decompiled Documentation EA 23.351.2 Nightly
Loading...
Searching...
No Matches
TCText.cs
Go to the documentation of this file.
1using System;
2using UnityEngine;
3using UnityEngine.UI;
4
5public class TCText : TCUI
6{
7 public static string[] popIDs = new string[4] { "PopTextSys", "PopTextGod", "PopTextASMR", "PopTextOPA" };
8
9 public PopManager pop;
10
11 [NonSerialized]
13
14 public override Vector3 FixPos => TC._setting.textPos;
15
16 public void Say(string s, float duration = 0f)
17 {
18 if (s.IsEmpty())
19 {
20 return;
21 }
22 string id;
23 float chance;
24 while (ExtractSoundTag(ref s, out id, out chance))
25 {
26 if (Rand.rndf(1f) <= chance)
27 {
28 base.owner.PlaySound(id);
29 }
30 }
31 PopItem p;
32 switch (s[0])
33 {
34 case '(':
35 p = pop.PopText(s, null, EMono.core.config.ui.balloonBG ? "PopText_alt" : "PopTextThinking", default(Color), default(Vector3), duration);
36 break;
37 case '*':
38 p = pop.PopText(s, null, "PopTextOno", default(Color), default(Vector3), duration);
39 break;
40 case '@':
41 {
42 int num = int.Parse(s[1].ToString());
43 p = pop.PopText(s.Substring(2), null, popIDs[num], default(Color), default(Vector3), duration);
44 if (num == 3)
45 {
46 Shaker.ShakeCam("opa");
47 }
48 break;
49 }
50 case '^':
51 p = pop.PopText(s.Substring(1), null, "PopTextBroadcast", default(Color), default(Vector3), duration);
52 break;
53 case '|':
54 p = pop.PopText(s.Substring(1), null, "PopTextAbility", default(Color), default(Vector3), duration);
55 break;
56 default:
57 p = pop.PopText(s, null, EMono.core.config.ui.balloonBG ? "PopText_alt" : "PopText", default(Color), default(Vector3), duration);
58 break;
59 }
60 if (!p)
61 {
62 return;
63 }
64 EMono.core.actionsNextFrame.Add(delegate
65 {
66 if (p != null && p.gameObject != null)
67 {
68 p.RebuildLayout(recursive: true);
69 ContentSizeFitter[] componentsInChildren = p.GetComponentsInChildren<ContentSizeFitter>();
70 for (int i = 0; i < componentsInChildren.Length; i++)
71 {
72 componentsInChildren[i].enabled = false;
73 }
74 LayoutGroup[] componentsInChildren2 = p.GetComponentsInChildren<LayoutGroup>();
75 for (int i = 0; i < componentsInChildren2.Length; i++)
76 {
77 componentsInChildren2[i].enabled = false;
78 }
79 }
80 });
81 }
82
83 public void ShowEmo(Emo emo, float duration)
84 {
85 Sprite sprite = SpriteSheet.Get("Media/Graphics/Icon/icons_32", "emo_" + emo);
86 if (lastEmo != null)
87 {
88 pop.Kill(lastEmo);
89 }
90 lastEmo = pop.PopText("", sprite, "PopTextEmo", default(Color), default(Vector3), duration);
91 }
92
93 public override void OnDraw(ref Vector3 pos)
94 {
95 if (!pop.enabled)
96 {
97 render.RemoveTC(this);
98 return;
99 }
100 Vector3 pos2 = pos;
101 lastPos = pos;
102 base.OnDraw(ref pos2);
103 }
104
105 public override void OnKill()
106 {
107 DrawImmediate(ref lastPos);
108 pop.CopyAll(EMono.ui.rectDynamic);
109 pop.KillAll(instant: true);
110 }
111
112 private static bool ExtractSoundTag(ref string text, out string id, out float chance)
113 {
114 id = null;
115 chance = 1f;
116 int num = text.IndexOf("<sound=", StringComparison.Ordinal);
117 if (num == -1)
118 {
119 return false;
120 }
121 int num2 = text.IndexOf('>', num);
122 if (num2 == -1)
123 {
124 return false;
125 }
126 int num3 = num + 7;
127 string text2 = text.Substring(num3, num2 - num3);
128 int num4 = text2.IndexOf(',');
129 if (num4 == -1)
130 {
131 id = text2;
132 }
133 else
134 {
135 id = text2[..num4];
136 float.TryParse(text2[(num4 + 1)..], out chance);
137 }
138 text = text.Remove(num, num2 - num + 1);
139 chance = Mathf.Clamp01(chance);
140 return true;
141 }
142}
Emo
Definition: Emo.cs:2
List< Action > actionsNextFrame
Definition: BaseCore.cs:31
new UISetting ui
Definition: CoreConfig.cs:621
CoreConfig config
Definition: Core.cs:70
Definition: EMono.cs:4
static Core core
Definition: EMono.cs:5
static UI ui
Definition: EMono.cs:15
PopItemText PopText(string text, Sprite sprite=null, string id="PopText", Color c=default(Color), Vector3 destPos=default(Vector3), float duration=0f)
Definition: PopManager.cs:41
Definition: Rand.cs:4
static float rndf(float max)
Definition: Rand.cs:68
Definition: Shaker.cs:5
static void ShakeCam(string id="default", float magnitude=1f)
Definition: Shaker.cs:25
static Sprite Get(string id)
Definition: SpriteSheet.cs:28
Definition: TCText.cs:6
void Say(string s, float duration=0f)
Definition: TCText.cs:16
override void OnDraw(ref Vector3 pos)
Definition: TCText.cs:93
PopManager pop
Definition: TCText.cs:9
override Vector3 FixPos
Definition: TCText.cs:14
PopItemText lastEmo
Definition: TCText.cs:12
void ShowEmo(Emo emo, float duration)
Definition: TCText.cs:83
static string[] popIDs
Definition: TCText.cs:7
override void OnKill()
Definition: TCText.cs:105
static bool ExtractSoundTag(ref string text, out string id, out float chance)
Definition: TCText.cs:112
Definition: TCUI.cs:4
Definition: TC.cs:4
static GameSetting.RenderSetting.TCSetting _setting
Definition: TC.cs:5