This repository was archived by the owner on Dec 28, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEngine.cs
More file actions
78 lines (72 loc) · 2.03 KB
/
Engine.cs
File metadata and controls
78 lines (72 loc) · 2.03 KB
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
namespace Rift.RiftEngine.Core
{
public static class Engine
{
public static Game? gameReference;
public static bool isInitialized = false;
public static bool isStarted = false;
public static void SetGameReference(Game reference)
{
gameReference = reference;
}
public static void Init()
{
if (!isInitialized)
{
isInitialized = true;
}
else
{
throw new GameAlreadyInitializedException("The game was already initialized.");
}
if (gameReference != null)
{
gameReference.Init();
} else
{
throw new GameReferenceNullException("The game reference is null.");
}
}
public static void Start()
{
if(!isInitialized)
{
throw new GameNotInitializedException("The game has not been initialized.");
}
if (!isStarted)
{
isStarted = true;
} else
{
throw new GameAlreadyRunningException("The game is already running.");
}
if (gameReference != null)
{
Events.GameStart.Trigger();
gameReference.Start();
}
else
{
throw new GameReferenceNullException("The game reference is null.");
}
}
public static void Stop()
{
if (isStarted)
{
isStarted = false;
} else
{
throw new GameNotRunningException("The game is not running.");
}
if (gameReference != null)
{
Events.GameStop.Trigger();
gameReference.Stop();
} else
{
throw new GameReferenceNullException("The game reference was null.");
}
}
}
}