Elin Modding Docs Doc
Loading...
Searching...
No Matches
LayerProgress.cs
1using System;
2using System.Threading;
3using Cysharp.Threading.Tasks;
4using DG.Tweening;
5using DG.Tweening.Core;
6using DG.Tweening.Plugins.Options;
7using UnityEngine;
8using UnityEngine.UI;
9
10// Token: 0x020005B5 RID: 1461
11public class LayerProgress : ELayer
12{
13 // Token: 0x0600280E RID: 10254 RVA: 0x000E239C File Offset: 0x000E059C
14 public void Init(string hint)
15 {
16 this.text.text = hint;
17 LayerProgress.completed = false;
18 LayerProgress.isActive = true;
19 LayerProgress.progress = (this.value = 0f);
20 this.cg.alpha = 0f;
21 this.cg.DOFade(1f, 0.1f).SetEase(Ease.InCubic).SetDelay(0.2f);
22 }
23
24 // Token: 0x0600280F RID: 10255 RVA: 0x000E240C File Offset: 0x000E060C
25 public void Update()
26 {
27 if (this.onCancel != null && Input.GetKeyDown(KeyCode.Escape))
28 {
29 LayerProgress.isActive = false;
30 this.Close();
31 this.onCancel();
32 return;
33 }
34 this.minTime -= Time.deltaTime;
35 if (LayerProgress.progress < 0.9f)
36 {
37 LayerProgress.progress += this.minProgress * Time.deltaTime;
38 }
39 this.value = Mathf.Lerp(this.value, LayerProgress.progress, Time.deltaTime * this.speed);
40 if (this.useUnitask && this.unitask.Status == UniTaskStatus.Succeeded)
41 {
42 LayerProgress.completed = true;
43 }
44 this.bar.value = Mathf.Clamp(this.value, 0f, 1f);
45 if (LayerProgress.completed && this.minTime < 0f)
46 {
47 LayerProgress.progress = 1f;
48 this.speed *= 5f;
49 this.endTime -= Time.deltaTime;
50 if (this.endTime > 0f)
51 {
52 return;
53 }
54 LayerProgress.isActive = false;
55 this.Close();
56 if (this.onComplete != null)
57 {
58 this.onComplete();
59 }
60 }
61 }
62
63 // Token: 0x06002810 RID: 10256 RVA: 0x000E2544 File Offset: 0x000E0744
64 public static LayerProgress StartAsync(string text, UniTask<bool> task, Action onCancel = null)
65 {
66 LayerProgress layerProgress = ELayer.ui.AddLayer<LayerProgress>();
67 layerProgress.Init(text);
68 layerProgress.useUnitask = true;
69 layerProgress.unitask = task;
70 layerProgress.onCancel = onCancel;
71 return layerProgress;
72 }
73
74 // Token: 0x06002811 RID: 10257 RVA: 0x000E256C File Offset: 0x000E076C
75 public static LayerProgress Start(string text, Action onComplete = null)
76 {
77 LayerProgress layerProgress = ELayer.ui.AddLayer<LayerProgress>();
78 layerProgress.Init(text);
79 layerProgress.onComplete = onComplete;
80 return layerProgress;
81 }
82
83 // Token: 0x06002812 RID: 10258 RVA: 0x000E2588 File Offset: 0x000E0788
84 public static void Start(string text, Action thread, Action onComplete)
85 {
86 if (ELayer.core.debug.dontUseThread)
87 {
88 thread();
89 onComplete();
90 return;
91 }
92 LayerProgress layerProgress = ELayer.ui.AddLayer<LayerProgress>();
93 layerProgress.Init(text);
94 layerProgress.onComplete = onComplete;
95 ThreadPool.QueueUserWorkItem(delegate(object a)
96 {
97 thread();
98 LayerProgress.completed = true;
99 });
100 }
101
102 // Token: 0x04001632 RID: 5682
103 public static bool completed;
104
105 // Token: 0x04001633 RID: 5683
106 public static bool isActive;
107
108 // Token: 0x04001634 RID: 5684
109 public static float progress;
110
111 // Token: 0x04001635 RID: 5685
112 public float speed;
113
114 // Token: 0x04001636 RID: 5686
115 public float minTime;
116
117 // Token: 0x04001637 RID: 5687
118 public float endTime;
119
120 // Token: 0x04001638 RID: 5688
121 public float minProgress;
122
123 // Token: 0x04001639 RID: 5689
124 public Slider bar;
125
126 // Token: 0x0400163A RID: 5690
127 public Text text;
128
129 // Token: 0x0400163B RID: 5691
130 public Action onComplete;
131
132 // Token: 0x0400163C RID: 5692
133 public Func<bool> funcComplete;
134
135 // Token: 0x0400163D RID: 5693
136 public UniTask<bool> unitask;
137
138 // Token: 0x0400163E RID: 5694
139 public Action onCancel;
140
141 // Token: 0x0400163F RID: 5695
142 public bool useUnitask;
143
144 // Token: 0x04001640 RID: 5696
145 public CanvasGroup cg;
146
147 // Token: 0x04001641 RID: 5697
148 private float value;
149}