77using System . Threading . Tasks ;
88using Raylib_cs ;
99using RayWrapper . Animation ;
10+ using RayWrapper . Animation . Transitions ;
1011using RayWrapper . CollisionSystem ;
1112using RayWrapper . Discord ;
1213using RayWrapper . GameConsole ;
@@ -43,7 +44,7 @@ public class GameBox
4344 public static Vector2 WindowSize { get ; private set ; }
4445 public static GameLoop Scene { get ; set ; }
4546 public static string Title { get ; private set ; }
46- public static GameBox Gb => _instance ;
47+ // public static GameBox Gb => _instance;
4748 public static bool IsMouseOccupied => mouseOccupier != null ;
4849 public static bool enableConsole = true ;
4950 public static float scale ;
@@ -52,7 +53,6 @@ public class GameBox
5253
5354 public static AlertBox alertBox = null ;
5455
55- // public static Animator animator = new();
5656 public static ColorModule backgroundColor = new ( 40 ) ;
5757 public static ColorModule letterboxColor = new ( 20 ) ;
5858 public static bool isDebugTool ;
@@ -74,9 +74,10 @@ public class GameBox
7474 private static bool _isDrawing ;
7575 private static bool _isConsole ;
7676 private static RenderTexture2D _target ;
77- private static GameBox _instance ;
77+ // private static GameBox _instance;
7878 private static bool _initDiscord ;
7979 private static bool _initCollision ;
80+ private static bool _hasInit ;
8081
8182 public static int FPS
8283 {
@@ -97,9 +98,9 @@ public static Font Font
9798 public GameBox ( GameLoop scene , Vector2 windowSize , string title = "Untitled Window" , int fps = 60 ,
9899 string iconPath = "" )
99100 {
100- if ( _instance is not null ) throw new ApplicationException ( "Only 1 instance of GameBox can be created" ) ;
101+ if ( _hasInit ) throw new ApplicationException ( "Only 1 instance of GameBox can be created" ) ;
101102 SetTraceLogCallback ( Logger . RayLog ) ;
102- _instance = this ;
103+ _hasInit = true ;
103104 SetConfigFlags ( ConfigFlags . FLAG_WINDOW_RESIZABLE ) ;
104105 ( Scene , WindowSize ) = ( scene , windowSize ) ;
105106 screenGrid = new ScreenGrid ( ) ;
@@ -118,7 +119,7 @@ public GameBox(GameLoop scene, Vector2 windowSize, string title = "Untitled Wind
118119 Start ( ) ;
119120 }
120121
121- private void Start ( )
122+ private static void Start ( )
122123 {
123124 Task . Run ( ( ) =>
124125 {
@@ -159,7 +160,7 @@ private void Start()
159160 Dispose ( ) ;
160161 }
161162
162- public void InitDiscord ( )
163+ public static void InitDiscord ( )
163164 {
164165 if ( _initDiscord ) return ;
165166 _initDiscord = true ;
@@ -168,7 +169,7 @@ public void InitDiscord()
168169 AddScheduler ( new Scheduler ( 100 , DiscordIntegration . UpdateActivity ) ) ;
169170 }
170171
171- public void InitCollision ( )
172+ public static void InitCollision ( )
172173 {
173174 if ( _initCollision ) return ;
174175 _initCollision = true ;
@@ -190,7 +191,7 @@ public void InitCollision()
190191 } ) ;
191192 }
192193
193- private void Update ( )
194+ private static void Update ( )
194195 {
195196 if ( f11Fullscreen && IsKeyPressed ( KeyboardKey . KEY_F11 ) )
196197 {
@@ -211,7 +212,7 @@ private void Update()
211212 Scene . Update ( ) ;
212213 }
213214
214- public void RenderRenderTexture ( RenderTexture2D texture2D , Vector2 pos , Action update , Action draw )
215+ public static void RenderRenderTexture ( RenderTexture2D texture2D , Vector2 pos , Action update , Action draw )
215216 {
216217 if ( ! _isDrawing ) return ;
217218 var before = new Vector2 ( mousePos . X , mousePos . Y ) ;
@@ -227,7 +228,7 @@ public void RenderRenderTexture(RenderTexture2D texture2D, Vector2 pos, Action u
227228 mousePos = before ;
228229 }
229230
230- public void Render ( )
231+ private static void Render ( )
231232 {
232233 BeginTextureMode ( _target ) ;
233234 _isDrawing = true ;
@@ -271,7 +272,7 @@ public void Render()
271272 _isDrawing = false ;
272273 }
273274
274- public void Dispose ( )
275+ private static void Dispose ( )
275276 {
276277 if ( _isDrawing ) EndDrawing ( ) ;
277278 _schedulers . Clear ( ) ;
@@ -281,22 +282,22 @@ public void Dispose()
281282 Environment . Exit ( 0 ) ;
282283 }
283284
284- public void AddScheduler ( Scheduler schedule ) => _schedulers . Add ( schedule ) ;
285- public void ChangeFps ( int fps ) => SetTargetFPS ( FPS = fps ) ;
285+ public static void AddScheduler ( Scheduler schedule ) => _schedulers . Add ( schedule ) ;
286+ public static void ChangeFps ( int fps ) => SetTargetFPS ( FPS = fps ) ;
286287 public static long GetTimeMs ( ) => DateTimeOffset . UtcNow . ToUnixTimeMilliseconds ( ) ;
287288
288289 # region save system
289290
290- public void InitSaveSystem ( string developerName , string appName ) =>
291+ public static void InitSaveSystem ( string developerName , string appName ) =>
291292 ( DeveloperName , AppName , SaveInit ) = ( developerName , appName , true ) ;
292293
293294 public static string GetSavePath => File . Exists ( "UseLocalPath" ) ? $ "{ AppName } " : $ "{ CoreDir } /{ DeveloperName } /{ AppName } ";
294- public void SaveItems ( ) => SaveList . SaveItems ( this ) ;
295- public void LoadItems ( ) => SaveList . LoadItems ( this ) ;
296- public void DeleteFile ( string name ) => SaveList . DeleteFile ( name , this ) ;
297- public void DeleteAll ( ) => SaveList . DeleteAll ( this ) ;
298- public void RegisterSaveItem < T > ( T obj , string fileName ) => SaveList . Add ( new SaveItem < T > ( obj , fileName ) ) ;
299- public void DeRegisterSaveItem ( string fileName ) => SaveList . RemoveAll ( m => m . FileName ( ) == fileName ) ;
295+ public static void SaveItems ( ) => SaveList . SaveItems ( ) ;
296+ public static void LoadItems ( ) => SaveList . LoadItems ( ) ;
297+ public static void DeleteFile ( string name ) => SaveList . DeleteFile ( name ) ;
298+ public static void DeleteAll ( ) => SaveList . DeleteAll ( ) ;
299+ public static void RegisterSaveItem < T > ( T obj , string fileName ) => SaveList . Add ( new SaveItem < T > ( obj , fileName ) ) ;
300+ public static void DeRegisterSaveItem ( string fileName ) => SaveList . RemoveAll ( m => m . FileName ( ) == fileName ) ;
300301
301302 #endregion
302303
@@ -308,7 +309,7 @@ public static void AddTime(long ms)
308309 timeAverage = CollisionTime . Sum ( ) / ( double ) CollisionTime . Length ;
309310 }
310311
311- public void CalcMousePos ( )
312+ public static void CalcMousePos ( )
312313 {
313314 var mouse = GetMousePosition ( ) ;
314315 scale = Math . Min ( GetScreenWidth ( ) / WindowSize . X , GetScreenHeight ( ) / WindowSize . Y ) ;
0 commit comments