blob: 48f5d5cfa60dcf26d39d25dc0fb0dea021443af6 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
|
using System;
using System.Collections;
using UnityEngine;
using XUtliPoolLib;
namespace XMainClient
{
public sealed class XAutoFade
{
private static float _in = 0f;
private static bool _force_from_black = false;
private static IEnumerator _fadeToBlack = null;
private static IEnumerator _fadeToClear = null;
private enum FadeType
{
ToBlack,
ToClear
}
public static void PostUpdate()
{
bool flag = XAutoFade._fadeToBlack != null;
if (flag)
{
bool flag2 = !XAutoFade._fadeToBlack.MoveNext();
if (flag2)
{
XAutoFade._fadeToBlack = null;
}
}
else
{
bool flag3 = XAutoFade._fadeToClear != null;
if (flag3)
{
bool flag4 = !XAutoFade._fadeToClear.MoveNext();
if (flag4)
{
XAutoFade._fadeToClear = null;
}
}
}
}
public static void MakeBlack(bool stopall = false)
{
if (stopall)
{
XAutoFade.StopAll();
}
XSingleton<XGameUI>.singleton.SetOverlayAlpha(1f);
}
public static void FadeOut2In(float In, float Out)
{
XAutoFade._in = In;
XAutoFade.FadeOut(Out);
}
public static void FadeIn(float duration, bool fromBlack = false)
{
XAutoFade.StopAll();
XAutoFade._force_from_black = fromBlack;
XAutoFade.Start(XAutoFade.FadeType.ToClear, duration);
}
public static void FadeOut(float duration)
{
XAutoFade.StopAll();
XAutoFade.Start(XAutoFade.FadeType.ToBlack, duration);
}
public static void FastFadeIn()
{
XAutoFade.StopAll();
XSingleton<XGameUI>.singleton.SetOverlayAlpha(0f);
}
private static IEnumerator FadeToBlack(float duration)
{
float alpha = XSingleton<XGameUI>.singleton.GetOverlayAlpha();
float rate = 1f / duration;
float progress = alpha;
while (progress < 1f && XSingleton<XGameUI>.singleton.GetOverlayAlpha() < 1f)
{
XSingleton<XGameUI>.singleton.SetOverlayAlpha(Mathf.Lerp(0f, 1f, progress));
progress += rate * ((Time.timeScale != 0f) ? (Time.deltaTime / Time.timeScale) : Time.unscaledDeltaTime);
yield return null;
}
XSingleton<XGameUI>.singleton.SetOverlayAlpha(1f);
bool flag = XAutoFade._in > 0f;
if (flag)
{
XAutoFade.FadeIn(XAutoFade._in, false);
XAutoFade._in = 0f;
}
yield break;
}
private static IEnumerator FadeToClear(float duration)
{
float alpha = XSingleton<XGameUI>.singleton.GetOverlayAlpha();
bool force_from_black = XAutoFade._force_from_black;
if (force_from_black)
{
alpha = 1f;
XSingleton<XGameUI>.singleton.SetOverlayAlpha(1f);
}
bool flag = duration == 0f;
if (flag)
{
alpha = 0f;
}
else
{
float rate = 1f / duration;
float progress = 1f - alpha;
while (progress < 1f && XSingleton<XGameUI>.singleton.GetOverlayAlpha() > 0f)
{
XSingleton<XGameUI>.singleton.SetOverlayAlpha(Mathf.Lerp(1f, 0f, progress));
progress += rate * ((Time.timeScale != 0f) ? (Time.deltaTime / Time.timeScale) : Time.unscaledDeltaTime);
yield return null;
}
}
XSingleton<XGameUI>.singleton.SetOverlayAlpha(0f);
yield break;
}
private static void Start(XAutoFade.FadeType type, float duration)
{
if (type != XAutoFade.FadeType.ToBlack)
{
if (type == XAutoFade.FadeType.ToClear)
{
bool flag = XAutoFade._fadeToClear == null;
if (flag)
{
XAutoFade._fadeToClear = XAutoFade.FadeToClear(duration);
}
}
}
else
{
bool flag2 = XAutoFade._fadeToBlack == null;
if (flag2)
{
XAutoFade._fadeToBlack = XAutoFade.FadeToBlack(duration);
}
}
}
private static void StopAll()
{
XAutoFade._fadeToBlack = null;
XAutoFade._fadeToClear = null;
}
}
}
|