Elin Decompiled Documentation EA 23.102 Nightly
Loading...
Searching...
No Matches
WidgetMascot.cs
Go to the documentation of this file.
1using System.IO;
2using UnityEngine;
3using UnityEngine.UI;
4
5public class WidgetMascot : Widget
6{
7 public RawImage image;
8
9 public UIText text;
10
11 public int intervalSay;
12
13 public string[] linesDefault;
14
15 public string[] linesSiege;
16
17 public string[] linesShutup;
18
19 public Vector2 textPos;
20
21 private int nextSay = 2;
22
23 private bool first = true;
24
25 private bool isSiege;
26
27 private bool isShut;
28
29 public override bool ShowStyleMenu => false;
30
31 public override void OnActivate()
32 {
33 string path = string.Concat(CorePath.coreWidget + base.config.id + "/", "default.png");
34 string obj = Lang.setting.dir + "Widget/" + base.config.id + "/";
35 string path2 = obj + "default.txt";
36 string path3 = obj + "siege.txt";
37 string path4 = obj + "shutup.txt";
38 if (File.Exists(path2))
39 {
40 linesDefault = IO.LoadTextArray(path2);
41 }
42 if (File.Exists(path3))
43 {
44 linesSiege = IO.LoadTextArray(path3);
45 }
46 if (File.Exists(path4))
47 {
48 linesShutup = IO.LoadTextArray(path4);
49 }
50 if (File.Exists(path))
51 {
52 image.texture = IO.LoadPNG(path);
53 }
54 Say("");
55 InvokeRepeating("_Update", 1f, 1f);
56 }
57
58 private void Update()
59 {
60 if (isShut && InputModuleEX.IsPointerOver(base.transform))
61 {
62 SE.Play("teleport");
63 base.transform.position = new Vector3(EMono.rnd(Screen.width), EMono.rnd(Screen.height), 0f);
66 }
67 }
68
69 public void _Update()
70 {
71 if (nextSay > 0)
72 {
73 nextSay--;
74 }
75 else
76 {
77 if (isShut)
78 {
79 return;
80 }
81 isSiege = EMono._zone.events.GetEvent<ZoneEventSiege>() != null;
82 string[] array = (isSiege ? linesSiege : linesDefault);
83 if (array != null)
84 {
85 string str = ((EMono.rnd(2) == 0) ? "" : array.RandomItem());
86 if (first)
87 {
88 str = array[0];
89 first = false;
90 }
91 Say(str);
92 }
93 }
94 }
95
96 public override void OnFlip()
97 {
98 image.transform.localScale = new Vector3(flip ? 1 : (-1), 1f, 1f);
99 }
100
101 public void Say(string[] lines)
102 {
103 Say(lines.RandomItem());
104 }
105
106 public void Say(string str)
107 {
108 Transform parent = text.transform.parent;
109 if (str.IsEmpty())
110 {
111 parent.SetActive(enable: false);
112 }
113 else
114 {
115 parent.SetActive(enable: true);
116 text.text = str;
118 }
120 if (isSiege)
121 {
122 nextSay /= 2;
123 }
124 }
125
126 public override void OnSetContextMenu(UIContextMenu m)
127 {
128 m.AddToggle("shutup", isShut, delegate(bool a)
129 {
130 isShut = a;
131 base.config.annoyPlayer = isShut;
132 if (isShut)
133 {
135 }
136 });
138 }
139}
static string coreWidget
Definition: CorePath.cs:188
Definition: EMono.cs:4
static Zone _zone
Definition: EMono.cs:19
static int rnd(int a)
Definition: EMono.cs:47
static bool IsPointerOver(Component c)
UIContextMenuItem AddToggle(string idLang="", bool isOn=false, UnityAction< bool > action=null)
Definition: UIText.cs:6
void Update()
Definition: WidgetMascot.cs:58
override void OnFlip()
Definition: WidgetMascot.cs:96
override void OnActivate()
Definition: WidgetMascot.cs:31
UIText text
Definition: WidgetMascot.cs:9
Vector2 textPos
Definition: WidgetMascot.cs:19
override bool ShowStyleMenu
Definition: WidgetMascot.cs:29
void Say(string str)
override void OnSetContextMenu(UIContextMenu m)
string[] linesDefault
Definition: WidgetMascot.cs:13
string[] linesShutup
Definition: WidgetMascot.cs:17
void Say(string[] lines)
string[] linesSiege
Definition: WidgetMascot.cs:15
void _Update()
Definition: WidgetMascot.cs:69
RawImage image
Definition: WidgetMascot.cs:7
Definition: Widget.cs:7
void SetBaseContextMenu(UIContextMenu m)
Definition: Widget.cs:608
void OnChangePosition()
Definition: Widget.cs:462
bool flip
Definition: Widget.cs:164
void ClampToScreenEnsured(Component c, Vector2 anchoredPos)
Definition: Widget.cs:424
void ClampToScreen()
Definition: Widget.cs:437
ZoneEventManager events
Definition: Zone.cs:40