1- using Intersect . Utilities ;
1+ using Intersect . Client . Networking ;
2+ using Intersect . Configuration ;
3+ using Intersect . Utilities ;
24
35namespace Intersect . Client . Core
46{
@@ -21,64 +23,80 @@ public enum FadeType
2123
2224 private static float sFadeAmt ;
2325
24- private static float sFadeRate = 3000f ;
26+ private static float sFadeDurationMs ;
2527
2628 private static long sLastUpdate ;
2729
28- public static void FadeIn ( )
30+ public static float Alpha => sFadeAmt * 255f ;
31+
32+ private static bool InformServer { get ; set ; }
33+
34+ public static void FadeIn ( float durationMs , bool informServer = false )
2935 {
36+ sFadeDurationMs = durationMs ;
3037 sCurrentAction = FadeType . In ;
31- sFadeAmt = 255f ;
38+ sFadeAmt = 1f ;
3239 sLastUpdate = Timing . Global . MillisecondsUtc ;
40+ InformServer = informServer ;
3341 }
3442
35- public static void FadeOut ( )
43+ public static void FadeOut ( float durationMs , bool informServer = false )
3644 {
45+ sFadeDurationMs = durationMs ;
3746 sCurrentAction = FadeType . Out ;
3847 sFadeAmt = 0f ;
3948 sLastUpdate = Timing . Global . MillisecondsUtc ;
49+ InformServer = informServer ;
4050 }
4151
42- public static void Cancel ( )
52+ public static void Cancel ( bool informServer = false )
4353 {
4454 sCurrentAction = FadeType . None ;
4555 sFadeAmt = default ;
56+ InformServerOfCompletion ( true ) ;
4657 }
4758
4859 public static bool DoneFading ( )
4960 {
5061 return sCurrentAction == FadeType . None ;
5162 }
5263
53- public static float GetFade ( )
54- {
55- return sFadeAmt ;
56- }
57-
5864 public static void Update ( )
5965 {
6066 if ( sCurrentAction == FadeType . In )
6167 {
62- sFadeAmt -= ( Timing . Global . MillisecondsUtc - sLastUpdate ) / sFadeRate * 255f ;
68+ sFadeAmt -= ( Timing . Global . MillisecondsUtc - sLastUpdate ) / sFadeDurationMs ;
6369 if ( sFadeAmt <= 0f )
6470 {
6571 sCurrentAction = FadeType . None ;
6672 sFadeAmt = 0f ;
73+
74+ InformServerOfCompletion ( ) ;
6775 }
6876 }
6977 else if ( sCurrentAction == FadeType . Out )
7078 {
71- sFadeAmt += ( Timing . Global . MillisecondsUtc - sLastUpdate ) / sFadeRate * 255f ;
72- if ( sFadeAmt >= 255f )
79+ sFadeAmt += ( Timing . Global . MillisecondsUtc - sLastUpdate ) / sFadeDurationMs ;
80+ if ( sFadeAmt >= 1 )
7381 {
7482 sCurrentAction = FadeType . None ;
75- sFadeAmt = 255f ;
83+ sFadeAmt = 1f ;
84+
85+ InformServerOfCompletion ( ) ;
7686 }
7787 }
7888
7989 sLastUpdate = Timing . Global . MillisecondsUtc ;
8090 }
8191
92+ private static void InformServerOfCompletion ( bool force = false )
93+ {
94+ if ( InformServer || force )
95+ {
96+ InformServer = false ;
97+ PacketSender . SendFadeCompletePacket ( ) ;
98+ }
99+ }
82100 }
83101
84102}
0 commit comments