File tree Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Expand file tree Collapse file tree 1 file changed +35
-0
lines changed Original file line number Diff line number Diff line change 1+ // ReSharper disable InvertIf
2+ // ReSharper disable CheckNamespace
3+ // ReSharper disable InconsistentNaming
4+
5+ using UnityEngine ;
6+ using System . Collections . Generic ;
7+
8+ namespace AbyssMoth
9+ {
10+ public static class WaitForSecondsCache
11+ {
12+ private static readonly Dictionary < float , WaitForSeconds > cache = new ( ) ;
13+
14+ public static IReadOnlyDictionary < float , WaitForSeconds > GetCache ( ) => cache ;
15+
16+ public static WaitForSeconds Get ( float time )
17+ {
18+ if ( ! cache . TryGetValue ( time , out var waitForSeconds ) )
19+ {
20+ waitForSeconds = new WaitForSeconds ( time ) ;
21+ cache [ time ] = waitForSeconds ;
22+
23+ #if UNITY_EDITOR
24+ // NOTE: Exclusively for displaying the contents of the storage on the screen.
25+ // Dependency: MonoSingleton (https://github.com/RimuruDev/MonoSingleton.git)
26+ WaitForSecondsDebugView . Instance ? . AddEntry ( time ) ;
27+ #endif
28+ }
29+
30+ return waitForSeconds ;
31+ }
32+
33+ public static void Reset ( ) => cache . Clear ( ) ;
34+ }
35+ }
You can’t perform that action at this time.
0 commit comments