-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathProgram.cs
74 lines (59 loc) · 1.55 KB
/
Program.cs
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
using System;
using System.Runtime.InteropServices.JavaScript;
using System.Threading;
using Celeste;
public static partial class Program
{
internal static void Main()
{
Console.WriteLine("Main()");
Celeste.Celeste._mainThreadId = Thread.CurrentThread.ManagedThreadId;
Settings.Initialize();
_ = Settings.Existed;
}
[JSExport()]
public static void StartGame()
{
game = new Celeste.Celeste();
SetMainLoop(MainLoop);
}
private static Celeste.Celeste game;
public static bool exitGame = false;
public static bool exited = false;
public static void SyncFS()
{
Sync(SyncCallback);
}
private static void SyncCallback()
{
Console.WriteLine("Synced!");
}
private static void MainLoop()
{
if (exited) return;
if (exitGame)
{
// RunThread.WaitAll();
SyncFS();
Audio.Unload();
exitGame = false;
exited = true;
StopMainLoop();
}
try
{
game.RunOneFrame();
}
catch (Exception e)
{
Console.Error.WriteLine(e);
throw;
}
}
[JSImport("setMainLoop", "main.js")]
internal static partial void SetMainLoop([JSMarshalAs<JSType.Function>] Action cb);
[JSImport("stopMainLoop", "main.js")]
internal static partial void StopMainLoop();
[JSImport("syncFs", "main.js")]
internal static partial void Sync([JSMarshalAs<JSType.Function>] Action cb);
}